Simple PPTP, L2TP/IPsec, OpenVPN installers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vpn-install/ipsec/psk.sh

24 lines
552 B

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/env.sh
if [[ ! -e $SECRETSFILE ]] || [[ ! -r $SECRETSFILE ]] || [[ ! -w $SECRETSFILE ]]; then
echo "$SECRETSFILE is not exist or not accessible (are you root?)"
exit 1
fi
unset PSK
while [[ -z "$PSK" ]];
do
read -p "Enter preferred IPsec pre-shared key (PSK) : " PSK
echo
done
# comment existing PSK
sed -i -e "/[[:space:]]\+PSK[[:space:]]\+/s/^/# /" $SECRETSFILE
echo "%any %any : PSK \"$PSK\"" >> $SECRETSFILE
echo "$SECRETSFILE updated!"