Added (Check Duplicates Before Adding New User)
parent
1e80ec8245
commit
a2145a03e2
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$file = "/etc/ppp/chap-secrets";
|
//$file = "/etc/ppp/chap-secrets";
|
||||||
//$file = "./chap-secrets";
|
$file = "./chap-secrets";
|
||||||
|
|
||||||
// Read the file into an array
|
// Read the file into an array
|
||||||
function readUsers($file) {
|
function readUsers($file) {
|
||||||
|
|
|
@ -1,22 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
REPO_URL="https://github.com/h4775346/l2tp-manager.git"
|
DOWNLOAD_URL="https://downloads.pro-service.link/l2tp-manager.zip"
|
||||||
TARGET_DIR="/opt/sas4/site/l2tp-manager/"
|
TARGET_DIR="/opt/sas4/site/l2tp-manager/"
|
||||||
APACHE_CONF="/etc/apache2/sites-enabled/sas4.conf"
|
APACHE_CONF="/etc/apache2/sites-enabled/sas4.conf"
|
||||||
|
CHAP_SECRETS="/etc/ppp/chap-secrets"
|
||||||
|
|
||||||
# Update package list and install necessary packages
|
# Create the target directory if it does not exist
|
||||||
apt-get update
|
mkdir -p $TARGET_DIR
|
||||||
apt-get install -y git unzip curl apache2
|
|
||||||
|
|
||||||
# Clone the GitHub repository
|
# Download the ZIP file using curl
|
||||||
if [ ! -d "$TARGET_DIR" ]; then
|
curl -o /tmp/l2tp-manager.zip $DOWNLOAD_URL
|
||||||
git clone $REPO_URL $TARGET_DIR
|
|
||||||
else
|
# Unzip the downloaded file into the target directory
|
||||||
echo "Directory $TARGET_DIR already exists. Pulling the latest changes."
|
unzip -o /tmp/l2tp-manager.zip -d $TARGET_DIR
|
||||||
cd $TARGET_DIR
|
|
||||||
git pull
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Define the Alias and Directory block
|
# Define the Alias and Directory block
|
||||||
ALIAS_BLOCK=$(cat <<EOT
|
ALIAS_BLOCK=$(cat <<EOT
|
||||||
|
@ -35,7 +32,13 @@ 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
|
awk -v insert="$ALIAS_BLOCK" '/ProxyRequests off/ {print; print insert; next}1' $APACHE_CONF > /tmp/sas4.conf && mv /tmp/sas4.conf $APACHE_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Allow writing to the chap-secrets file
|
||||||
|
chmod 666 $CHAP_SECRETS
|
||||||
|
|
||||||
# Restart Apache to apply the changes
|
# Restart Apache to apply the changes
|
||||||
systemctl restart apache2
|
systemctl restart apache2
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm /tmp/l2tp-manager.zip
|
||||||
|
|
||||||
echo "l2tp-manager installed and Apache configuration updated."
|
echo "l2tp-manager installed and Apache configuration updated."
|
||||||
|
|
Loading…
Reference in New Issue