1#!/bin/sh 2 3PROGS="@PROGS@" 4PIDDIR="/var/run" 5DAEMON="hyperv" 6 7# shellcheck source=/dev/null 8[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" 9 10# only continue if we are in a HyperV platform 11[ -e "/sys/bus/vmbus" ] || exit 0 12 13start_one() { 14 printf 'Starting %s: ' "$1" 15 # shellcheck disable=SC2086 # we need the word splitting 16 start-stop-daemon -b -m -S -q -p "$PIDDIR/$1.pid" -x "/usr/sbin/$1" -- -n 17 status=$? 18 if [ "$status" -eq 0 ]; then 19 echo "OK" 20 else 21 echo "FAIL" 22 fi 23 return $status 24} 25 26start() { 27 # shellcheck disable=SC2086 # we need the word splitting 28 for prog in ${PROGS}; do 29 start_one "${prog}" || ret=$? 30 done 31 return "$ret" 32} 33 34stop_one() { 35 printf 'Stopping %s: ' "$1" 36 start-stop-daemon -K -q -p "$PIDDIR/$1.pid" 37 status=$? 38 if [ "$status" -eq 0 ]; then 39 rm -f "$PIDDIR/$1.pid" 40 echo "OK" 41 else 42 echo "FAIL" 43 fi 44 return $status 45} 46 47stop() { 48 # shellcheck disable=SC2086 # we need the word splitting 49 for prog in ${PROGS}; do 50 stop_one "${prog}" || ret=$? 51 done 52 return "$ret" 53} 54 55restart() { 56 stop 57 sleep 1 58 start 59} 60 61case "$1" in 62 start|stop|restart) 63 "$1";; 64 reload) 65 # Restart, since there is no true "reload" feature. 66 restart;; 67 *) 68 echo "Usage: $0 {start|stop|restart|reload}" 69 exit 1 70esac 71