aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Simon Rowe <simon.rowe@citrix.com>2019-09-18 09:59:35 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-09-18 17:52:36 +0200
commit21262616cac2b3c45db448a8f4f473cacf0197dc (patch)
tree9bf0612360594114aa048520b959c541c29f492a
parent48cc4d658f36ce44c48daf510d4a44dd9985875c (diff)
downloadbuildroot-21262616cac2b3c45db448a8f4f473cacf0197dc.tar.gz
buildroot-21262616cac2b3c45db448a8f4f473cacf0197dc.tar.bz2
package/openvmtools: base sysv script on current template
Signed-off-by: Simon Rowe <simon.rowe@citrix.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
-rw-r--r--package/openvmtools/S10vmtoolsd73
1 files changed, 47 insertions, 26 deletions
diff --git a/package/openvmtools/S10vmtoolsd b/package/openvmtools/S10vmtoolsd
index 5fdb5682f6..60ee875c0f 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