aboutsummaryrefslogtreecommitdiff
path: root/package/openvpn
diff options
context:
space:
mode:
authorGravatar Maxim Kochetkov <fido_max@inbox.ru>2020-10-02 09:47:21 +0300
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2020-10-08 23:24:44 +0200
commitd8e68597a78218d3d9c5cc53b8da0ddfe21f34d1 (patch)
tree5fc2f397364664aa8cb109b9dc6f26a329771a29 /package/openvpn
parenta6c7e0c0c3fa5515629c3f1d6c7fe8fc5107db96 (diff)
downloadbuildroot-d8e68597a78218d3d9c5cc53b8da0ddfe21f34d1.tar.gz
buildroot-d8e68597a78218d3d9c5cc53b8da0ddfe21f34d1.tar.bz2
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>
Diffstat (limited to 'package/openvpn')
-rw-r--r--package/openvpn/S60openvpn14
1 files 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