hello 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. ### BEGIN INIT INFO
  4. # Provides: hello
  5. # Required-Start: $local_fs $remote_fs $network $syslog
  6. # Required-Stop: $local_fs $remote_fs $network $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: Startup daemon script for hello
  10. ### END INIT INFO
  11. #
  12. # Author: Ludovic Gasc <[email protected]>
  13. set -e
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  15. DAEMONNAME=hello
  16. RUNDIR=/run/$DAEMONNAME
  17. DAEMON=/opt/hello/${DAEMONNAME}_cli
  18. PIDFILE=/run/lock/${DAEMONNAME}_0
  19. DAEMON_ARGS=""
  20. # Exit if the package is not installed
  21. [ -x "$DAEMON" ] || exit 0
  22. # Create RUNDIR if it doesn't exist
  23. [ -d "$RUNDIR" ] || mkdir -p "$RUNDIR"
  24. # Read configuration variable file if it is present
  25. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  26. # Load the VERBOSE setting and other rcS variables
  27. [ -f /etc/default/rcS ] && . /etc/default/rcS
  28. # Define LSB log_* functions.
  29. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  30. . /lib/lsb/init-functions
  31. case "$1" in
  32. start)
  33. log_daemon_msg "Starting" "$DAEMONNAME"
  34. if start-stop-daemon -b --start --pidfile $PIDFILE --startas $DAEMON -- $DAEMON_ARGS;
  35. then
  36. log_end_msg 0
  37. else
  38. log_end_msg 1
  39. fi
  40. ;;
  41. stop)
  42. log_daemon_msg "Stopping" "$DAEMONNAME"
  43. if start-stop-daemon --stop --retry 5 --pidfile $PIDFILE;
  44. then
  45. log_end_msg 0
  46. else
  47. log_end_msg 1
  48. fi
  49. ;;
  50. reload|force-reload)
  51. log_daemon_msg "Reloading" "$DAEMONNAME"
  52. if start-stop-daemon --stop --signal 1 --pidfile $PIDFILE --startas $DAEMON;
  53. then
  54. log_end_msg 0
  55. else
  56. log_end_msg 1
  57. fi
  58. ;;
  59. restart)
  60. $0 stop
  61. $0 start
  62. ;;
  63. status)
  64. status_of_proc -p $PIDFILE "$DAEMON" $DAEMONNAME && exit 0 || exit $?
  65. ;;
  66. *)
  67. echo "Usage: $0 {start|stop|reload|force-reload|restart|status}"
  68. exit 1
  69. ;;
  70. esac
  71. exit 0