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