S10hyperv 1.1 KB

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