From 92325d27ed53a7fe8fce09defee89db178d9f7e5 Mon Sep 17 00:00:00 2001 From: Bruno BEAUFILS <bruno@boulgour.com> Date: Wed, 4 Apr 2018 18:16:07 +0200 Subject: [PATCH] =?UTF-8?q?vpn:=20ajout=20restart=20=C3=A0=20vpnlille1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vpn/vpnlille1 | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/vpn/vpnlille1 b/vpn/vpnlille1 index 09e62a9..3a5b289 100755 --- a/vpn/vpnlille1 +++ b/vpn/vpnlille1 @@ -6,6 +6,7 @@ # COMMANDE # start démarre une connection au VPN personnels de Lille 1 # stop stoppe la connection au VPN personnels de Lille 1 +# restart stop puis start # conf génère un fichier LILLE1.ovpn # -h, --help, help affiche ce message d'aide @@ -131,18 +132,34 @@ EOF # doc is included as comments from 2nd line of the script to first empty line doc () { sed -n '2,/^$/ { s/^ *#// ; s/^ //g ; t e ; d ; :e p }' <$0 ; } +# démarrer le vpn +start_vpn () +{ + verifie sudo + verifie openvpn + sudo openvpn --daemon \ + --config ${vpnconf} +} + +# arrêter le vpn +stop_vpn () +{ + verifie pgrep + pid=$(pgrep openvpn) + test -z "$pid" || sudo kill $pid +} + # Le travail effectif case "$1" in "start") - verifie sudo - verifie openvpn - sudo openvpn --daemon \ - --config ${vpnconf} + start_vpn ;; "stop") - verifie pgrep - pid=$(pgrep openvpn) - test -z "$pid" || sudo kill $pid + stop_vpn + ;; + "restart") + stop_vpn + start_vpn ;; "conf") cp ${vpnconf} . -- GitLab