simple_init.j2 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: alfred
  4. # Required-Start: $remote_fs $network
  5. # Required-Stop: $remote_fs $network
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: A.L.F.R.E.D
  9. ### END INIT INFO
  10. # Author: Nils Schneider <nils@nilsschneider.net>
  11. PATH=/sbin:/bin
  12. DESC="{{item.description}}"
  13. NAME={{item.name}}
  14. DAEMON={{item.daemon_path}}$NAME
  15. PIDFILE=/var/run/$NAME.pid
  16. SCRIPTNAME=/etc/init.d/$NAME
  17. OPTIONS=""
  18. UMASK=0117
  19. [ -x "$DAEMON" ] || exit 0
  20. # Source defaults.
  21. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  22. [ -n "$INTERFACE" ] && OPTIONS="$OPTIONS -i $INTERFACE"
  23. [ -n "$BATMANIF" ] && OPTIONS="$OPTIONS -b $BATMANIF"
  24. [ "$MASTER" = "1" ] && OPTIONS="$OPTIONS -m"
  25. [ -n "$DAEMON_OPTS" ] && OPTIONS="$OPTIONS $DAEMON_OPTS"
  26. . /lib/lsb/init-functions
  27. case "$1" in
  28. start)
  29. log_daemon_msg "Starting $DESC" "$NAME"
  30. start-stop-daemon --start --quiet --pidfile "$PIDFILE" \
  31. --umask $UMASK --make-pidfile \
  32. --background --exec "$DAEMON" --oknodo \
  33. -- $OPTIONS
  34. log_end_msg $?
  35. ;;
  36. stop)
  37. log_daemon_msg "Stopping $DESC" "$NAME"
  38. start-stop-daemon --stop --quiet --pidfile "$PIDFILE" \
  39. --retry 1 --oknodo
  40. log_end_msg $?
  41. ;;
  42. restart|force-reload)
  43. $0 stop
  44. sleep 1
  45. $0 start
  46. ;;
  47. status)
  48. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  49. ;;
  50. *)
  51. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
  52. exit 1
  53. ;;
  54. esac
  55. exit $?