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 <fido_max@inbox.ru>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Maxim Kochetkov 2020-10-02 09:47:21 +03:00 committed by Thomas Petazzoni
parent a6c7e0c0c3
commit d8e68597a7

View File

@ -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