Passage à systemctl, le nom du vpn change avec jessie

This commit is contained in:
Gabriel Detraz 2015-09-01 17:55:03 +02:00
parent 72bde6ca25
commit f77a73218d

View file

@ -4,9 +4,7 @@ MAIN_ROUTER=odlyd
BACK_ROUTER=freebox
vpn_is_running () {
local pid_file
pid_file=/var/run/openvpn.$1.pid
if [ -f $pid_file ] && [ -d /proc/$(< $pid_file) ]
if systemctl is-active openvpn@$1
then return 0
else return 1
fi
@ -19,7 +17,7 @@ vpn_start () {
then
touch /tmp/vpn_mail_sent
# On utilise restart pour être sûr de ne pas avec de VPN qui traîne
if /etc/init.d/openvpn restart $1
if systemctl restart openvpn@$1
then
echo "Lancement du vpn $(hostname)<->$1 reussi "'!'
exit 0
@ -28,7 +26,7 @@ vpn_start () {
exit 1
fi
else
/etc/init.d/openvpn restart $1 &> /dev/null
systemctl restart openvpn@$1 &> /dev/null
fi
}
@ -43,9 +41,9 @@ if fping -q $MAIN_ROUTER.crans.org; then
then
if ! [ -f /tmp/vpn_mail_sent ] || [ $((`date +%s` - `stat -c %X /tmp/vpn_mail_sent`)) -gt 300 ]
then
/etc/init.d/openvpn stop $BACK_ROUTER
systemctl stop openvpn@$BACK_ROUTER
else
/etc/init.d/openvpn stop $BACK_ROUTER &> /dev/null
systemctl stop openvpn@$BACK_ROUTER &> /dev/null
fi
fi
vpn_start $MAIN_ROUTER