1.0.0
This commit is contained in:
		
							parent
							
								
									c634d66af2
								
							
						
					
					
						commit
						8fba36f2ce
					
				@ -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 <<EOT
 | 
			
		||||
Alias /l2tp-manager $TARGET_DIR
 | 
			
		||||
<Directory $TARGET_DIR>
 | 
			
		||||
    Order allow,deny
 | 
			
		||||
    Allow from all
 | 
			
		||||
    AllowOverride All
 | 
			
		||||
    Require all granted
 | 
			
		||||
</Directory>
 | 
			
		||||
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."
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user