From 5b3e7019d4af81507b250c856a1aac7a8097449b Mon Sep 17 00:00:00 2001 From: Bkeenke <128972800+bkeenke@users.noreply.github.com> Date: Thu, 25 Apr 2024 01:54:31 +0300 Subject: [PATCH] Update awg-manager.sh --- awg-manager.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/awg-manager.sh b/awg-manager.sh index 784a29c..234396c 100755 --- a/awg-manager.sh +++ b/awg-manager.sh @@ -18,6 +18,7 @@ function usage { echo " -L : Lock user" echo " -U : Unlock user" echo " -p : Print user config" + echo " -q : Print user QR code" echo " -u : User identifier (uniq field for vpn account)" echo " -s : Server host for user connection" echo " -I : Interface (default auto)" @@ -42,6 +43,7 @@ while getopts ":icdpqhLUu:I:s:" opt; do L) LOCK=1 ;; U) UNLOCK=1 ;; p) PRINT_USER_CONFIG=1 ;; + q) PRINT_QR_CODE=1 ;; u) USER="$OPTARG" ;; I) SERVER_INTERFACE="$OPTARG" ;; h) usage ;; @@ -78,6 +80,11 @@ function get_new_ip { echo "${SERVER_IP_PREFIX}.${IP}/32" } +function encode { + python3 encode.py ${USER} > keys/${USER}/${USER}.vpn +} + + function add_user_to_server { if [ ! -f "keys/${USER}/public.key" ]; then echo "ERROR: User not exists" >&2 @@ -208,7 +215,7 @@ AllowedIPs = 0.0.0.0/0 PersistentKeepalive = 20 PresharedKey = ${USER_PSK_KEY} EOF - + encode add_user_to_server reload_server } @@ -255,7 +262,8 @@ fi if [ $PRINT_USER_CONFIG ]; then cat "keys/${USER}/${USER}.conf" +elif [ $PRINT_QR_CODE ]; then + qrencode -t ansiutf8 < "keys/${USER}/${USER}.vpn" fi exit 0 -