init.j2 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides: wifi-with-me
  5. # Required-Start: $syslog $local_fs $remote_fs
  6. # Required-Stop: $syslog $local_fs $remote_fs
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: Wifi-with-me form
  10. # Description: Get good will from people :)
  11. #
  12. ### END INIT INFO
  13. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  14. INSTALL_DIR={{ wwm_install_dir }}
  15. DAEMON=${INSTALL_DIR}/backend.py
  16. NAME=wifi-with-me
  17. DESC="Wifi with me, formulaire wifi"
  18. test -x $DAEMON || exit 0
  19. RUN_AS_USER={{ wwm_user }}
  20. set -e
  21. case "$1" in
  22. start)
  23. echo -n "Starting $DESC: "
  24. start-stop-daemon -d $INSTALL_DIR -b --start --quiet \
  25. --chuid $RUN_AS_USER --exec $DAEMON -- $DAEMON_OPTS
  26. echo "$NAME."
  27. ;;
  28. stop)
  29. echo -n "Stopping $DESC: "
  30. start-stop-daemon --stop --oknodo --quiet \
  31. --exec $DAEMON
  32. echo "$NAME."
  33. ;;
  34. force-reload)
  35. # check whether $DAEMON is running. If so, restart
  36. start-stop-daemon --stop --test --quiet \
  37. --exec $DAEMON -- $DAEMON_OPTS \
  38. && $0 restart \
  39. || exit 0
  40. ;;
  41. restart)
  42. echo -n "Restarting $DESC: "
  43. start-stop-daemon --stop --oknodo --quiet \
  44. --exec $DAEMON
  45. sleep 1
  46. start-stop-daemon -d $INSTALL_DIR -b --start --quiet \
  47. --chuid $RUN_AS_USER --exec $DAEMON -- $DAEMON_OPTS
  48. echo "$NAME."
  49. ;;
  50. *)
  51. N=/etc/init.d/$NAME
  52. echo "Usage: $N {start|stop|restart|force-reload}" >&2
  53. exit 1
  54. ;;
  55. esac
  56. exit 0