Advertisement
tietutz

sample odoo bootable script

Aug 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: openerp-server
  4. # Required-Start: $syslog
  5. # Required-Stop: $syslog
  6. # Should-Start: $network
  7. # Should-Stop: $network
  8. # Default-Start: 2 3 4 5
  9. # Default-Stop: 0 1 6
  10. # Short-Description: OpenERP Server
  11. # Description: OpenERP is a complete ERP and CRM software.
  12. ### END INIT INFO
  13.  
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/
  15. #DAEMON=/usr/local/bin/odoo-server
  16. DAEMON=/usr/local/bin/odoo-server
  17. NAME=odoo-server
  18. DESC=odoo-server
  19. # Specify the user name (Default: openerp).
  20. USER="odoo"
  21. # Specify an alternate config file (Default: /etc/openerp-server.conf).
  22. CONFIGFILE="/etc/odoo-server.conf"
  23. # pidfile
  24. PIDFILE=/var/run/$NAME.pid
  25. # Additional options that are passed to the Daemon.
  26. #DAEMON_OPTS="-c $CONFIGFILE --update=all"
  27. #DAEMON_OPTS="-c $CONFIGFILE --init=all"
  28. DAEMON_OPTS="-c $CONFIGFILE"
  29. [ -x $DAEMON ] || exit 0
  30. [ -f $CONFIGFILE ] || exit 0
  31. checkpid() {
  32. [ -f $PIDFILE ] || return 1
  33. pid=`cat $PIDFILE`
  34. [ -d /proc/$pid ] && return 0
  35. return 1
  36. }
  37. if [ -f /lib/lsb/init-functions ] || [ -f /etc/gentoo-release ] ;
  38. then
  39. do_start() {
  40. start-stop-daemon --start --quiet --pidfile $PIDFILE \
  41. --chuid $USER --background --make-pidfile \
  42. --exec $DAEMON -- $DAEMON_OPTS
  43. RETVAL=$?
  44. sleep 5
  45. # wait for few seconds
  46. return $RETVAL
  47. }
  48. do_stop() {
  49. start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
  50. RETVAL=$?
  51. sleep 2
  52. rm -f $PIDFILE
  53. # wait for few seconds
  54. # remove pidfile
  55. return $RETVAL
  56. }
  57. do_restart() {
  58. start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
  59. sleep 2
  60. rm -f $PIDFILE
  61. # wait for few seconds
  62. # remove pidfile
  63. start-stop-daemon --start --quiet --pidfile $PIDFILE \
  64. --chuid $USER --background --make-pidfile \
  65. --exec $DAEMON -- $DAEMON_OPTS
  66. RETVAL=$?
  67. sleep 5
  68. # wait for few seconds
  69. return $RETVAL
  70. }
  71. else
  72. do_start() {
  73. $DAEMON $DAEMON_OPTS > /dev/null 2>&1 &
  74. RETVAL=$?
  75. sleep 5
  76. # wait for few seconds
  77. echo $! > $PIDFILE
  78. return $RETVAL
  79. # create pidfile
  80. }
  81. do_stop() {
  82. pid=`cat $PIDFILE`
  83. kill -15 $pid
  84. RETVAL=$?
  85. sleep 2
  86. rm -f $PIDFILE
  87. # wait for few seconds
  88. # remove pidfile
  89. return $RETVAL
  90. }
  91. do_restart() {
  92. if [ -f $PIDFILE ]; then
  93. do_stop
  94. fi
  95. do_start
  96. return $?
  97. }
  98. fi
  99. start_daemon() {
  100. if [ -f $PIDFILE ]; then
  101. echo "pidfile already exists: $PIDFILE"
  102. exit 1
  103. fi
  104. echo -n "Starting $DESC: "
  105. do_start
  106. checkpid
  107. if [ $? -eq 1 ]; then
  108. rm -f $PIDFILE
  109. echo "failed."
  110. exit 1
  111. fi
  112. echo "done."
  113. }
  114. stop_daemon() {
  115. checkpid
  116. if [ $? -eq 1 ]; then
  117. exit 0
  118. fi
  119. echo -n "Stopping $DESC: "
  120. do_stop
  121. if [ $? -eq 1 ]; then
  122. echo "failed."
  123. exit 1
  124. fi
  125. echo "done."
  126. }
  127. restart_daemon() {
  128. echo -n "Reloading $DESC: "
  129. do_restart
  130. checkpid
  131. if [ $? -eq 1 ]; then
  132. rm -f $PIDFILE
  133. echo "failed."
  134. exit 1
  135. fi
  136. echo "done."
  137. }
  138. status_daemon() {
  139. echo -n "Checking $DESC: "
  140. checkpid
  141. if [ $? -eq 1 ]; then
  142. echo "stopped."
  143. else
  144. echo "running."
  145. fi
  146. }
  147. case "$1" in
  148. start) start_daemon ;;
  149. stop) stop_daemon ;;
  150. restart|force-reload) restart_daemon ;;
  151. status) status_daemon ;;
  152. *)
  153. N=/etc/init.d/$NAME
  154. echo "Usage: $N {start|stop|restart|force-reload|status}">&2
  155. exit 1
  156. ;;
  157. esac
  158. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement