2
0

init-script.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: batcave
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Batman/Alfred Transmission Collection, Aggregation & Value Engine
  9. # Description: Collects and combines data from batman_adv and alfred for dissemination to other parties.
  10. ### END INIT INFO
  11. DAEMON_DIR="/opt/batcave/"
  12. DAEMON_NAME=batcave
  13. # Add any command line options for your daemon here
  14. DAEMON_OPTS=""
  15. # This next line determines what user the daemon runs as.
  16. # Root is required to gather data from batadv_vis.
  17. DAEMON_USER=root
  18. # The process ID of the script when it runs is stored here:
  19. PIDFILE=/var/run/$DAEMON_NAME.pid
  20. [ -r "/etc/default/$DAEMON_NAME" ] && . /etc/default/${DAEMON_NAME}
  21. DAEMON="${DAEMON_DIR}/${DAEMON_NAME}.py"
  22. . /lib/lsb/init-functions
  23. do_start () {
  24. log_daemon_msg "Starting $DAEMON_NAME daemon"
  25. start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
  26. log_end_msg $?
  27. }
  28. do_stop () {
  29. log_daemon_msg "Stopping $DAEMON_NAME daemon"
  30. start-stop-daemon --stop --pidfile $PIDFILE --retry 10
  31. log_end_msg $?
  32. }
  33. case "$1" in
  34. start|stop)
  35. do_${1}
  36. ;;
  37. restart|force-reload)
  38. do_stop
  39. do_start
  40. ;;
  41. status)
  42. status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
  43. ;;
  44. *)
  45. echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
  46. exit 1
  47. ;;
  48. esac
  49. exit 0