From d8e68597a78218d3d9c5cc53b8da0ddfe21f34d1 Mon Sep 17 00:00:00 2001 From: Maxim Kochetkov Date: Fri, 2 Oct 2020 09:47:21 +0300 Subject: [PATCH] package/openvpn: use start-stop-daemon to perform start/stop actions Using 'start-stop-daemon' prevents multiple instances creation by '/etc/init.d/S60openvpn start'. Signed-off-by: Maxim Kochetkov Signed-off-by: Thomas Petazzoni --- package/openvpn/S60openvpn | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package/openvpn/S60openvpn b/package/openvpn/S60openvpn index bc1ab01c1a..f097cf11ec 100644 --- a/package/openvpn/S60openvpn +++ b/package/openvpn/S60openvpn @@ -11,13 +11,15 @@ CONFIG_DIR=/etc/openvpn test -d $CONFIG_DIR || exit 0 start_vpn () { - /usr/sbin/openvpn --daemon --writepid /var/run/openvpn.$NAME.pid \ - --config $CONFIG_DIR/$NAME.conf --cd $CONFIG_DIR || printf " FAILED->" - printf " $NAME" + printf " $NAME " + start-stop-daemon -S -p /var/run/openvpn.$NAME.pid -x /usr/sbin/openvpn -- \ + --daemon --writepid /var/run/openvpn.$NAME.pid \ + --config $CONFIG_DIR/$NAME.conf --cd $CONFIG_DIR + [ $? = 0 ] && echo "OK" || echo "FAIL" } stop_vpn () { - kill `cat $PIDFILE` || true - rm $PIDFILE + printf " $NAME " + start-stop-daemon -K -p /var/run/openvpn.$NAME.pid -x /usr/sbin/openvpn } case "$1" in @@ -48,7 +50,6 @@ stop) NAME=`echo $PIDFILE | cut -c18-` NAME=${NAME%%.pid} stop_vpn - printf " $NAME" done else if test -e /var/run/openvpn.$2.pid ; then @@ -56,7 +57,6 @@ stop) NAME=`echo $PIDFILE | cut -c18-` NAME=${NAME%%.pid} stop_vpn - printf " $NAME" else printf " No such VPN: $2" fi -- 2.30.2