S10hyperv 1.2 KB

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