init.j2 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. PIDFILE=/var/run/wifiwithme.pid
  17. NAME=wifi-with-me
  18. DESC="Wifi with me, formulaire wifi"
  19. test -x $DAEMON || exit 0
  20. RUN_AS_USER={{ wwm_user }}
  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 \
  26. --pidfile $PIDFILE --make-pidfile \
  27. -- $DAEMON_OPTS
  28. echo "$NAME."
  29. ;;
  30. stop)
  31. echo -n "Stopping $DESC: "
  32. start-stop-daemon -d $INSTALL_DIR --stop --oknodo \
  33. --pidfile $PIDFILE && rm $PIDFILE
  34. echo "$NAME."
  35. ;;
  36. force-reload)
  37. # check whether $DAEMON is running. If so, restart
  38. start-stop-daemon --stop --test --quiet \
  39. --pidfile $PIDFILE \
  40. -- $DAEMON_OPTS \
  41. && $0 restart \
  42. || exit 0
  43. ;;
  44. restart)
  45. echo "Restarting $DESC: " \
  46. && $0 stop \
  47. && $0 start \
  48. || exit 0
  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