Skip to contentSkip to conversation

package/openvmtools: base SYSV script on current template

PATCH New Simon Rowe 2 participants 2 messages Sep 18, 2019

lore
Share & tools
lore

Simon Rowe

author
#0 lore raw

PATCH 1/1 package/openvmtools: base SYSV script on current template

---
 package/openvmtools/S10vmtoolsd | 73 ++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 26 deletions(-)
package/openvmtools/S10vmtoolsd +47 -26
index 5fdb568..60ee875 100644
@@ -3,33 +3,54 @@
 # Starts vmtoolsd for openvmtools
 #
 
-EXEC="/usr/bin/vmtoolsd"
-ARGS="-b"
-PID="/var/run/vmtoolsd.pid"
+DAEMON="vmtoolsd"
+PIDFILE="/var/run/$DAEMON.pid"
 
-[ -r /etc/default/vmtoolsd ] && . /etc/default/vmtoolsd
+VMTOOLSD_ARGS="-b"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/bin/$DAEMON" \
+		-- $VMTOOLSD_ARGS "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+restart() {
+	stop
+	sleep 1
+	start
+}
 
 case "$1" in
-  start)
-    printf "Starting vmtoolsd: "
-    start-stop-daemon -S -q -x $EXEC -- $ARGS $PID
-    if [ $? != 0 ]; then
-      echo "FAILED"
-      exit 1
-    else
-      echo "OK"
-    fi
-  ;;
-  stop)
-    printf "Stopping vmtoolsd: "
-    start-stop-daemon -K -q -p $PID
-    echo "OK"
-  ;;
-  restart|reload)
-    $0 stop
-    $0 start
-  ;;
-  *)
-    echo "Usage: $0 {start|stop|restart}"
-    exit 1
+	start|stop|restart)
+		"$1";;
+	reload)
+		# Restart, since there is no true "reload" feature.
+		restart;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload}"
+		exit 1
 esac
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 package/openvmtools: base SYSV script on current template

Quoted 4 lines · On Wed, 18 Sep 2019 09:59:35 +0100 Simon Rowe <[email protected]> wrote:
---
 package/openvmtools/S10vmtoolsd | 73 ++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 26 deletions(-)

Applied to master, thanks.

Thomas

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