From 8fba36f2ce91cf74da415e53446ee8212a9573e6 Mon Sep 17 00:00:00 2001 From: h4775346 Date: Mon, 1 Jul 2024 17:40:50 +0300 Subject: [PATCH] 1.0.0 --- sas4-installer.sh | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/sas4-installer.sh b/sas4-installer.sh index d16956c..864f777 100644 --- a/sas4-installer.sh +++ b/sas4-installer.sh @@ -1 +1,41 @@ -#/bin/bash +#!/bin/bash + +# Define variables +REPO_URL="https://github.com/h4775346/l2tp-manager.git" +TARGET_DIR="/opt/sas4/site/l2tp-manager/" +APACHE_CONF="/etc/apache2/sites-enabled/sas4.conf" + +# Update package list and install necessary packages +apt-get update +apt-get install -y git unzip curl apache2 + +# Clone the GitHub repository +if [ ! -d "$TARGET_DIR" ]; then + git clone $REPO_URL $TARGET_DIR +else + echo "Directory $TARGET_DIR already exists. Pulling the latest changes." + cd $TARGET_DIR + git pull +fi + +# Define the Alias and Directory block +ALIAS_BLOCK=$(cat < + Order allow,deny + Allow from all + AllowOverride All + Require all granted + +EOT +) + +# Add the new Alias and Directory block to the Apache configuration if it does not already exist +if ! grep -q "/l2tp-manager/" $APACHE_CONF; then + awk -v insert="$ALIAS_BLOCK" '/ProxyRequests off/ {print; print insert; next}1' $APACHE_CONF > /tmp/sas4.conf && mv /tmp/sas4.conf $APACHE_CONF +fi + +# Restart Apache to apply the changes +systemctl restart apache2 + +echo "l2tp-manager installed and Apache configuration updated."