S60dockerd 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. DAEMON="dockerd"
  3. PIDFILE="/var/run/$DAEMON.pid"
  4. DOCKERD_ARGS=""
  5. # shellcheck source=/dev/null
  6. [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
  7. start() {
  8. printf 'Starting %s: ' "$DAEMON"
  9. # Dockerd logs only to stdout/stderr, which is lost with
  10. # --background. The wrapper script runs the given command
  11. # (after "--", including dockerd) and forwards stdout/stderr
  12. # to syslog.
  13. # shellcheck disable=SC2086 # we need word splitting for DOCKERD_ARGS
  14. start-stop-daemon --start --background --pidfile "$PIDFILE" \
  15. --exec /usr/libexec/dockerd-syslog-wrapper.sh \
  16. -- "/usr/bin/$DAEMON" --pidfile "$PIDFILE" $DOCKERD_ARGS
  17. status=$?
  18. if [ "$status" -eq 0 ]; then
  19. echo "OK"
  20. else
  21. echo "FAIL"
  22. fi
  23. return "$status"
  24. }
  25. stop() {
  26. printf 'Stopping %s: ' "$DAEMON"
  27. start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/bin/$DAEMON"
  28. status=$?
  29. if [ "$status" -eq 0 ]; then
  30. echo "OK"
  31. else
  32. echo "FAIL"
  33. return "$status"
  34. fi
  35. while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
  36. --exec "/usr/bin/$DAEMON"; do
  37. sleep 0.1
  38. done
  39. rm -f "$PIDFILE"
  40. return "$status"
  41. }
  42. restart() {
  43. stop
  44. start
  45. }
  46. reload() {
  47. printf "Reloading %s config: " "$DAEMON"
  48. start-stop-daemon --stop --signal HUP -q --pidfile "$PIDFILE" \
  49. --exec "/usr/bin/$DAEMON"
  50. status=$?
  51. if [ "$status" -eq 0 ]; then
  52. echo "OK"
  53. else
  54. echo "FAIL"
  55. fi
  56. return "$status"
  57. }
  58. case "$1" in
  59. start|stop|restart|reload)
  60. "$1";;
  61. *)
  62. echo "Usage: $0 {start|stop|restart|reload}"
  63. exit 1
  64. esac