diff --git a/wireguard/peer_install.sh b/wireguard/peer_install.sh new file mode 100755 index 0000000..f9cfb68 --- /dev/null +++ b/wireguard/peer_install.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +WGPORTAL_URL=http://185.123.84.125:8123/ +WG_CONFFILE=/etc/wireguard/wg0.conf + +trap 'stty echo' INT + +if [ -f "$WG_CONFFILE" -a $OVERWRITE -ne 1 ]; then + printf "Wireguard config file already exists\n" + printf "Exiting now to prevent overrid of your actual parameters\n" + exit 1; +fi + +printf "Username: " +IFS= read -r username + +printf "Password: " +stty -echo +IFS= read -r password +stty echo +printf "\n" + +HTTP_STATUS=$(curl -w "%{http_code}" -s -o $WG_CONFFILE --user $username:$password -X GET $WGPORTAL_URL"api/v1/provisioning/peer/mqQiS1kYWDoXlvhucqMIGkBeUjy7yppZ0eLLENsM5UU%3D" -H "accept: text/plain") +res=$? +if test "$res" != "0"; then + echo "the curl command failed with: $res" +fi +