Skip to contentSkip to conversation

package/openvpn: Use start-stop-daemon to perform start/stop actions

PATCH New Maxim Kochetkov 2 participants 2 messages Oct 2, 2020 – Oct 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/openvpn: Use start-stop-daemon to perform start/stop actions

Using 'start-stop-daemon' prevents multiple instances creation by '/etc/init.d/S60openvpnv start'.

---
 package/openvpn/S60openvpn | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
package/openvpn/S60openvpn +6 -7
index bc1ab01c1a..63530a6f13 100644
@@ -11,13 +11,14 @@ 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 +49,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 +56,6 @@ stop)
       NAME=`echo $PIDFILE | cut -c18-`
       NAME=${NAME%%.pid}
       stop_vpn
-      printf " $NAME"
     else
       printf " No such VPN: $2"
     fi
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/1 package/openvpn: Use start-stop-daemon to perform start/stop actions

Quoted 6 lines · On Fri, 2 Oct 2020 09:47:21 +0300 Maxim Kochetkov via buildroot…

Using 'start-stop-daemon' prevents multiple instances creation by '/etc/init.d/S60openvpnv start'.

---
 package/openvpn/S60openvpn | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com