Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/openvmtools: base SYSV script on current template
@ 2019-09-18  8:59 Simon Rowe
  2019-09-18 15:53 ` Thomas Petazzoni
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Rowe @ 2019-09-18  8:59 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Simon Rowe <simon.rowe@citrix.com>
---
 package/openvmtools/S10vmtoolsd | 73 ++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 26 deletions(-)

diff --git a/package/openvmtools/S10vmtoolsd b/package/openvmtools/S10vmtoolsd
index 5fdb568..60ee875 100644
--- a/package/openvmtools/S10vmtoolsd
+++ b/package/openvmtools/S10vmtoolsd
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Buildroot] [PATCH 1/1] package/openvmtools: base SYSV script on current template
  2019-09-18  8:59 [Buildroot] [PATCH 1/1] package/openvmtools: base SYSV script on current template Simon Rowe
@ 2019-09-18 15:53 ` Thomas Petazzoni
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni @ 2019-09-18 15:53 UTC (permalink / raw)
  To: buildroot

On Wed, 18 Sep 2019 09:59:35 +0100
Simon Rowe <simon.rowe@citrix.com> wrote:

> Signed-off-by: Simon Rowe <simon.rowe@citrix.com>
> ---
>  package/openvmtools/S10vmtoolsd | 73 ++++++++++++++++++++++++++---------------
>  1 file changed, 47 insertions(+), 26 deletions(-)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-18 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-18  8:59 [Buildroot] [PATCH 1/1] package/openvmtools: base SYSV script on current template Simon Rowe
2019-09-18 15:53 ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox