Advertisement
Guest User

pidfileprobeersel

a guest
Jan 19th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: nefit easy http server
  4. # Required-Start: $network $remote_fs $syslog
  5. # Required-Stop: $network $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: nefit-easy-http-server
  9. # Description: This daemon will start the nefit-easy-http-server for use by Domoticz
  10. ### END INIT INFO
  11.  
  12. # Do NOT "set -e"
  13.  
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  15. DESC="Nefit Easy HTTP Server"
  16. NAME=easy-server
  17. USERNAME=root
  18. PIDFILE=/var/run/$NAME.pid
  19. SCRIPTNAME=/etc/init.d/$NAME
  20. NEFIT_SERIAL_NUMBER=serienummer
  21. NEFIT_ACCESS_KEY=accesskey
  22. NEFIT_PASSWORD=wachtwoord
  23. NEFIT_HOST=192.168.0.124
  24. NEFIT_PORT=3001
  25.  
  26.  
  27. DAEMON=/usr/local/bin/$NAME
  28.  
  29. DAEMON_ARGS="$DAEMON_ARGS --serial=$NEFIT_SERIAL_NUMBER"
  30. DAEMON_ARGS="$DAEMON_ARGS --access-key=$NEFIT_ACCESS_KEY"
  31. DAEMON_ARGS="$DAEMON_ARGS --password=$NEFIT_PASSWORD"
  32. DAEMON_ARGS="$DAEMON_ARGS --host=$NEFIT_HOST"
  33. DAEMON_ARGS="$DAEMON_ARGS --port=$NEFIT_PORT"
  34.  
  35.  
  36. # Exit if the package is not installed
  37. [ -x "$DAEMON" ] || exit 0
  38.  
  39. #
  40. # Function that starts the daemon/service
  41. #
  42. do_start()
  43. {
  44.  
  45. echo `ps w | grep ${DESC} | grep -v -E 'grep' | awk '{print $1}' > $PIDFILE`
  46. nohup $DAEMON $DAEMON_ARGS &
  47.  
  48.  
  49. }
  50.  
  51. #
  52. # Function that stops the daemon/service
  53. #
  54.  
  55. do_stop()
  56.  
  57. {
  58. # Kill the application
  59. kill `cat ${PIDFILE}`
  60. wait_for_status 1 20 || kill -9 `cat ${PIDFILE}`
  61. rm -f ${PIDFILE}
  62. }
  63.  
  64.  
  65.  
  66. case "$1" in
  67. start)
  68. do_start
  69. ;;
  70. stop)
  71. do_stop
  72. ;;
  73. restart)
  74. do_stop
  75. do_start
  76. ;;
  77. *)
  78. echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
  79. exit 3
  80. ;;
  81. esac
  82.  
  83. :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement