pptp adduser proc refactoring

This commit is contained in:
bedefaced 2017-08-18 18:48:14 +03:00 committed by bedefaced
parent 1b484cf3c4
commit 4f950271de
3 changed files with 62 additions and 54 deletions

View File

@ -15,6 +15,5 @@ conn L2TP-PSK-NAT
dpddelay=30 dpddelay=30
dpdtimeout=120 dpdtimeout=120
dpdaction=clear dpdaction=clear
keyexchange=ikev2
ike=aes128-sha1-modp1024,aes128-sha1-modp1536,aes128-sha1-modp2048,aes128-sha256-ecp256,aes128-sha256-modp1024,aes128-sha256-modp1536,aes128-sha256-modp2048,aes256-aes128-sha256-sha1-modp2048-modp4096-modp1024,aes256-sha1-modp1024,aes256-sha256-modp1024,aes256-sha256-modp1536,aes256-sha256-modp2048,aes256-sha256-modp4096,aes256-sha384-ecp384,aes256-sha384-modp1024,aes256-sha384-modp1536,aes256-sha384-modp2048,aes256-sha384-modp4096,aes256gcm16-aes256gcm12-aes128gcm16-aes128gcm12-sha256-sha1-modp2048-modp4096-modp1024,3des-sha1-modp1024! ike=aes128-sha1-modp1024,aes128-sha1-modp1536,aes128-sha1-modp2048,aes128-sha256-ecp256,aes128-sha256-modp1024,aes128-sha256-modp1536,aes128-sha256-modp2048,aes256-aes128-sha256-sha1-modp2048-modp4096-modp1024,aes256-sha1-modp1024,aes256-sha256-modp1024,aes256-sha256-modp1536,aes256-sha256-modp2048,aes256-sha256-modp4096,aes256-sha384-ecp384,aes256-sha384-modp1024,aes256-sha384-modp1536,aes256-sha384-modp2048,aes256-sha384-modp4096,aes256gcm16-aes256gcm12-aes128gcm16-aes128gcm12-sha256-sha1-modp2048-modp4096-modp1024,3des-sha1-modp1024!
esp=aes128-aes256-sha1-sha256-modp2048-modp4096-modp1024,aes128-sha1,aes128-sha1-modp1024,aes128-sha1-modp1536,aes128-sha1-modp2048,aes128-sha256,aes128-sha256-ecp256,aes128-sha256-modp1024,aes128-sha256-modp1536,aes128-sha256-modp2048,aes128gcm12-aes128gcm16-aes256gcm12-aes256gcm16-modp2048-modp4096-modp1024,aes128gcm16,aes128gcm16-ecp256,aes256-sha1,aes256-sha256,aes256-sha256-modp1024,aes256-sha256-modp1536,aes256-sha256-modp2048,aes256-sha256-modp4096,aes256-sha384,aes256-sha384-ecp384,aes256-sha384-modp1024,aes256-sha384-modp1536,aes256-sha384-modp2048,aes256-sha384-modp4096,aes256gcm16,aes256gcm16-ecp384,3des-sha1! esp=aes128-aes256-sha1-sha256-modp2048-modp4096-modp1024,aes128-sha1,aes128-sha1-modp1024,aes128-sha1-modp1536,aes128-sha1-modp2048,aes128-sha256,aes128-sha256-ecp256,aes128-sha256-modp1024,aes128-sha256-modp1536,aes128-sha256-modp2048,aes128gcm12-aes128gcm16-aes256gcm12-aes256gcm16-modp2048-modp4096-modp1024,aes128gcm16,aes128gcm16-ecp256,aes256-sha1,aes256-sha256,aes256-sha256-modp1024,aes256-sha256-modp1536,aes256-sha256-modp2048,aes256-sha256-modp4096,aes256-sha384,aes256-sha384-ecp384,aes256-sha384-modp1024,aes256-sha384-modp1536,aes256-sha384-modp2048,aes256-sha384-modp4096,aes256gcm16,aes256gcm16-ecp384,3des-sha1!

View File

@ -8,28 +8,34 @@ if [[ ! -e $CHAPSECRETS ]] || [[ ! -r $CHAPSECRETS ]] || [[ ! -w $CHAPSECRETS ]]
exit 1 exit 1
fi fi
if [[ $# -gt 0 ]]; then ADDUSER="no"
ANSUSER="yes"
while [ "$ANSUSER" != "$ADDUSER" ];
do
if [[ $# -gt 0 ]]; then
LOGIN="$1" LOGIN="$1"
fi fi
while [[ -z "$LOGIN" ]]; while [[ -z "$LOGIN" ]];
do do
read -p "Enter name: " LOGIN read -p "Enter name: " LOGIN
done done
unset PASSWORD unset PASSWORD
while [[ -z "$PASSWORD" ]]; while [[ -z "$PASSWORD" ]];
do do
read -p "Enter password: " PASSWORD read -p "Enter password: " PASSWORD
echo echo
done done
DELETED=0 DELETED=0
$DIR/checkuser.sh $LOGIN $DIR/checkuser.sh $LOGIN
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
NOTREM="no" NOTREM="no"
read -p "User '$LOGIN' already exists. Do you want to remove existing user? [no] " ANSREM read -p "User '$LOGIN' already exists. Do you want to remove existing user? [no] " ANSREM
: ${ANSREM:=$NOTREM} : ${ANSREM:=$NOTREM}
@ -40,25 +46,34 @@ if [[ $? -eq 0 ]]; then
$DIR/deluser.sh $LOGIN $DIR/deluser.sh $LOGIN
DELETED=1 DELETED=1
fi fi
fi fi
echo -e "$LOGIN\t *\t $PASSWORD\t *" >> $CHAPSECRETS echo -e "$LOGIN\t *\t $PASSWORD\t *" >> $CHAPSECRETS
if [ $DELETED -eq 0 ]; then if [ $DELETED -eq 0 ]; then
echo "$CHAPSECRETS updated!" echo "$CHAPSECRETS updated!"
fi fi
STARTDIR=$(pwd) STARTDIR=$(pwd)
mkdir "$STARTDIR/$LOGIN" mkdir "$STARTDIR/$LOGIN"
DISTFILE=$STARTDIR/$LOGIN/setup.sh DISTFILE=$STARTDIR/$LOGIN/setup.sh
cp -rf setup.sh.dist "$DISTFILE" cp -rf setup.sh.dist "$DISTFILE"
sed -i -e "s@_LOGIN_@$LOGIN@g" "$DISTFILE" sed -i -e "s@_LOGIN_@$LOGIN@g" "$DISTFILE"
sed -i -e "s@_PASSWORD_@$PASSWORD@g" "$DISTFILE" sed -i -e "s@_PASSWORD_@$PASSWORD@g" "$DISTFILE"
sed -i -e "s@_REMOTEIP_@$IP@g" "$DISTFILE" sed -i -e "s@_REMOTEIP_@$IP@g" "$DISTFILE"
sed -i -e "s@_LOCALPREFIX_@$LOCALPREFIX@g" "$DISTFILE" sed -i -e "s@_LOCALPREFIX_@$LOCALPREFIX@g" "$DISTFILE"
chmod +x "$DISTFILE" chmod +x "$DISTFILE"
USERNAME=${SUDO_USER:-$USER} USERNAME=${SUDO_USER:-$USER}
chown -R $USERNAME:$USERNAME $STARTDIR/$LOGIN/ chown -R $USERNAME:$USERNAME $STARTDIR/$LOGIN/
echo echo
echo "Created directory $STARTDIR/$LOGIN with client-side installation file." echo "Created directory $STARTDIR/$LOGIN with client-side installation file."
if [[ $# -eq 0 ]]; then
echo
read -p "Would you want add another user? [no] " ANSUSER
: ${ANSUSER:=$ADDUSER}
else
ANSUSER=$ADDUSER
fi
done

View File

@ -17,13 +17,7 @@ ANSUSER="yes"
echo echo
echo "Configuring VPN users..." echo "Configuring VPN users..."
while [ "$ANSUSER" != "$ADDUSER" ]; $DIR/adduser.sh
do
$DIR/adduser.sh
read -p "Would you want add another user? [no] " ANSUSER
: ${ANSUSER:=$ADDUSER}
done
echo echo
echo "Configuring iptables firewall..." echo "Configuring iptables firewall..."