Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hwdsl2 committed Dec 22, 2018
1 parent 294faa2 commit 0b71d37
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ vpn_gen_env="/opt/src/vpn-gen.env"
if [ -z "$VPN_IPSEC_PSK" ] && [ -z "$VPN_USER" ] && [ -z "$VPN_PASSWORD" ]; then
if [ -f "$vpn_env" ]; then
echo
echo "Retrieving VPN credentials..."
echo 'Retrieving VPN credentials...'
. "$vpn_env"
elif [ -f "$vpn_gen_env" ]; then
echo
echo "Retrieving previously generated VPN credentials..."
echo 'Retrieving previously generated VPN credentials...'
. "$vpn_gen_env"
else
echo
echo "VPN credentials not set by user. Generating random PSK and password..."
echo 'VPN credentials not set by user. Generating random PSK and password...'
VPN_IPSEC_PSK="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 20)"
VPN_USER=vpnuser
VPN_PASSWORD="$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' < /dev/urandom | head -c 16)"

echo "VPN_IPSEC_PSK=$VPN_IPSEC_PSK" > "$vpn_gen_env"
echo "VPN_USER=$VPN_USER" >> "$vpn_gen_env"
echo "VPN_PASSWORD=$VPN_PASSWORD" >> "$vpn_gen_env"
printf '%s\n' "VPN_IPSEC_PSK='$VPN_IPSEC_PSK'" > "$vpn_gen_env"
printf '%s\n' "VPN_USER='$VPN_USER'" >> "$vpn_gen_env"
printf '%s\n' "VPN_PASSWORD='$VPN_PASSWORD'" >> "$vpn_gen_env"
chmod 600 "$vpn_gen_env"
fi
fi
Expand Down

0 comments on commit 0b71d37

Please sign in to comment.