Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: fuelwebsocket
  4. # Required-Start: $local_fs $network $named $time $syslog
  5. # Required-Stop: $local_fs $network $named $time $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Description: Script like as zver
  9. ### END INIT INFO
  10.  
  11. SCRIPT="env FUEL_ENV=production /usr/local/bin/php /var/www/html/oil r server"
  12. RUNAS="root"
  13. NAME=fuelwebsocket
  14.  
  15. PIDFILE=/var/run/$NAME.pid
  16. LOGFILE=/var/log/$NAME.log
  17.  
  18. start() {
  19. if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
  20. echo 'Service already running' >&2
  21. return 1
  22. fi
  23. echo 'Starting service…' >&2
  24. local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
  25. su -c "$CMD" $RUNAS > "$PIDFILE"
  26. echo 'Service started' >&2
  27. }
  28.  
  29. stop() {
  30. if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
  31. echo 'Service not running' >&2
  32. return 1
  33. fi
  34. echo 'Stopping service…' >&2
  35. kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  36. echo 'Service stopped' >&2
  37. }
  38.  
  39. uninstall() {
  40. echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
  41. local SURE
  42. read SURE
  43. if [ "$SURE" = "yes" ]; then
  44. stop
  45. rm -f "$PIDFILE"
  46. echo "Notice: log file is not be removed: '$LOGFILE'" >&2
  47. update-rc.d -f $NAME remove
  48. rm -fv "$0"
  49. fi
  50. }
  51.  
  52. case "$1" in
  53. start)
  54. start
  55. ;;
  56. stop)
  57. stop
  58. ;;
  59. uninstall)
  60. uninstall
  61. ;;
  62. retart)
  63. stop
  64. start
  65. ;;
  66. *)
  67. echo "Usage: $0 {start|stop|restart|uninstall}"
  68. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement