Browse Source

Add IP variable verification

pull/1/head
Julien Escario 5 years ago
parent
commit
a2b72f62ad
  1. 8
      wireguard/deploy-wg-clients.sh

8
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;
Loading…
Cancel
Save