VPN proxy changes - download key
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
84
install.sh
84
install.sh
@@ -39,32 +39,72 @@ ask_envs() {
|
||||
VPN_PROXY="no";
|
||||
else
|
||||
VPN_PROXY="yes";
|
||||
echo "Please add a valid vpn hash key:";
|
||||
while read -r VPN_HASH; do
|
||||
if [ "$VPN_HASH" != "" ]; then
|
||||
$SUDO_CMD mkdir -p /etc/user/secret/vpn-proxy;
|
||||
echo $VPN_HASH | base64 -d > /tmp/wg0.conf;
|
||||
$SUDO_CMD mv /tmp/wg0.conf /etc/user/secret/vpn-proxy/;
|
||||
break;
|
||||
fi;
|
||||
done
|
||||
|
||||
echo "Please add the letsencrypt mail address:";
|
||||
while read -r LETSENCRYPT_MAIL; do
|
||||
if [ "$LETSENCRYPT_MAIL" != "" ]; then
|
||||
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '@')" != "" ]; then
|
||||
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '\.')" != "" ]; then
|
||||
break;
|
||||
while true; do
|
||||
|
||||
echo "Please add domain url to download the VPN hash from (default: https://demo.format.hu): ";
|
||||
read -r VPN_DOMAIN;
|
||||
if [ "$VPN_DOMAIN" == "" ]; then
|
||||
VPN_DOMAIN="https://demo.format.hu";
|
||||
fi;
|
||||
|
||||
VPN_KEY="";
|
||||
echo "Please type in the generated VPN passkey (8 digits):";
|
||||
while read -r VPN_PASS; do
|
||||
if [ "$VPN_PASS" != "" ]; then
|
||||
dateFromServer=$(curl -v --silent https://demo.format.hu/ 2>&1 | grep -i '< date' | sed -e 's/< date: //gi')
|
||||
VPN_DATE=$(date +"%Y%m%d" -d "$dateFromServer");
|
||||
VPN_HASH=$(echo -n $(( $VPN_PASS * $VPN_DATE )));
|
||||
VPN_URL="$VPN_DOMAIN/$VPN_HASH";
|
||||
echo "DEBUG: $VPN_URL";
|
||||
HTTP_CODE=$(curl -s -I -w "%{http_code}" $VPN_URL -o /dev/null);
|
||||
break;
|
||||
fi;
|
||||
done
|
||||
|
||||
echo "DEBUG: $HTTP_CODE";
|
||||
if [ "$HTTP_CODE" == "200" ]; then
|
||||
# download VPN key
|
||||
VPN_KEY=$(curl -s $VPN_URL);
|
||||
echo $VPN_KEY;
|
||||
|
||||
$SUDO_CMD mkdir -p /etc/user/secret/vpn-proxy;
|
||||
echo $VPN_KEY | base64 -d > /tmp/wg0.conf;
|
||||
$SUDO_CMD mv /tmp/wg0.conf /etc/user/secret/vpn-proxy/;
|
||||
break;
|
||||
else
|
||||
echo "Download of VPN KEY was unsuccessful from URL: $VPN_URL";
|
||||
|
||||
echo "Do you want to retry? (Y/n)";
|
||||
read -r VPN_RETRY;
|
||||
if [ "$VPN_RETRY" == "n" ] || [ "$VPN_RETRY" == "N" ]; then
|
||||
VPN_PROXY="no";
|
||||
break;
|
||||
fi
|
||||
fi;
|
||||
|
||||
done;
|
||||
|
||||
echo "VPN proxy was skipped.";
|
||||
|
||||
if [ "$VPN_PROXY" == "yes" ]; then
|
||||
echo "Please add the letsencrypt mail address:";
|
||||
while read -r LETSENCRYPT_MAIL; do
|
||||
if [ "$LETSENCRYPT_MAIL" != "" ]; then
|
||||
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '@')" != "" ]; then
|
||||
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '\.')" != "" ]; then
|
||||
break;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
echo "Invalid email address.";
|
||||
done
|
||||
echo "Invalid email address.";
|
||||
done
|
||||
|
||||
echo "Please add letsencrypt server name (default is letsencrypt but you can add zerossl too):";
|
||||
read -r LETSENCRYPT_SERVERNAME;
|
||||
if [ "$LETSENCRYPT_SERVERNAME" = "" ]; then
|
||||
LETSENCRYPT_SERVERNAME="letsencrypt";
|
||||
echo "Please add letsencrypt server name (default is letsencrypt but you can add zerossl too):";
|
||||
read -r LETSENCRYPT_SERVERNAME;
|
||||
if [ "$LETSENCRYPT_SERVERNAME" = "" ]; then
|
||||
LETSENCRYPT_SERVERNAME="letsencrypt";
|
||||
fi;
|
||||
fi;
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user