init 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: odoo
  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: Start odoo daemon at boot time
  9. # Description: Enable service provided by daemon.
  10. # X-Interactive: true
  11. ### END INIT INFO
  12. ## more info: http://wiki.debian.org/LSBInitScripts
  13. . /lib/lsb/init-functions
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  15. DAEMON=/usr/bin/odoo
  16. NAME=odoo
  17. DESC=odoo
  18. CONFIG=/etc/odoo/odoo.conf
  19. LOGFILE=/var/log/odoo/odoo-server.log
  20. PIDFILE=/var/run/${NAME}.pid
  21. USER=odoo
  22. export LOGNAME=$USER
  23. test -x $DAEMON || exit 0
  24. set -e
  25. function _start() {
  26. start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
  27. }
  28. function _stop() {
  29. start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
  30. rm -f $PIDFILE
  31. }
  32. function _status() {
  33. start-stop-daemon --status --quiet --pidfile $PIDFILE
  34. return $?
  35. }
  36. case "$1" in
  37. start)
  38. echo -n "Starting $DESC: "
  39. _start
  40. echo "ok"
  41. ;;
  42. stop)
  43. echo -n "Stopping $DESC: "
  44. _stop
  45. echo "ok"
  46. ;;
  47. restart|force-reload)
  48. echo -n "Restarting $DESC: "
  49. _stop
  50. sleep 1
  51. _start
  52. echo "ok"
  53. ;;
  54. status)
  55. echo -n "Status of $DESC: "
  56. _status && echo "running" || echo "stopped"
  57. ;;
  58. *)
  59. N=/etc/init.d/$NAME
  60. echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
  61. exit 1
  62. ;;
  63. esac
  64. exit 0