From a2b72f62ad656f52548659f816195c01f9f87147 Mon Sep 17 00:00:00 2001 From: Julien Escario Date: Tue, 21 Apr 2020 17:00:17 +0200 Subject: [PATCH] Add IP variable verification --- wireguard/deploy-wg-clients.sh | 8 ++++++++ 1 file changed, 8 insertions(+) mode change 100644 => 100755 wireguard/deploy-wg-clients.sh diff --git a/wireguard/deploy-wg-clients.sh b/wireguard/deploy-wg-clients.sh old mode 100644 new mode 100755 index 42de6ac..8a9d1ed --- a/wireguard/deploy-wg-clients.sh +++ b/wireguard/deploy-wg-clients.sh @@ -1,5 +1,12 @@ #!/bin/bash +#re='^[0-9]{1,3}$' +if ! [[ $IP =~ ^[0-9]{1,3}$ ]] ; then + echo "error: Please set IP variable (with IP=1-254. See https://phpipam.altinea.fr" >&2; exit 1 +fi + +exit 1; + mkdir -p /etc/wireguard/keys umask 077 && wg genkey > /etc/wireguard/keys/private.key && wg pubkey < /etc/wireguard/keys/private.key > /etc/wireguard/keys/public.key && umask 0022 @@ -21,3 +28,4 @@ systemctl enable wg-quick@wg0.service && systemctl daemon-reload && systemctl st echo -n "Clé publique : " cat /etc/wireguard/keys/public.key +exit 0; \ No newline at end of file