template 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. # Begin $RC_BASE/init.d/template
  3. ### BEGIN INIT INFO
  4. # Provides: template
  5. # Required-Start:
  6. # Should-Start:
  7. # Required-Stop:
  8. # Should-Stop:
  9. # Default-Start:
  10. # Default-Stop:
  11. # Short-Description:
  12. # Description:
  13. # X-LFS-Provided-By:
  14. ### END INIT INFO
  15. # Source the LSB init-functions, ours are pulled in from there.
  16. . /lib/lsb/init-functions
  17. # These are optional, but required for chk_stat. They will be used in
  18. # the rest of the functions if defined, else you must provide a program
  19. # name to control, and a message ('Starting Template Service...'
  20. # or 'Stoping Template Service...') to evauate_retval. See the
  21. # documentaion in the lfs-fucntions file for more information.
  22. MESSAGE="Template Service"
  23. BIN_FILE="/some/path/to/template"
  24. CONFIGFILE="/etc/default/template.conf"
  25. # check that $BIN_FILE exists and is executable, and $CONFIGFILE exists.
  26. chk_stat
  27. # LSB Defined functions require that at least $BIN_FILE be passed to them,
  28. # where as lfs-functions will use the $BIN_FILE environment variable.
  29. # loadproc() and endproc() are just wrappers that pass everything on to
  30. # the LSB defined functions.
  31. case "${1}" in
  32. start)
  33. #start_daemon "${BIN_FILE}" -arg1 -arg2 #... or:
  34. loadproc -arg1 -arg2 -arg3 #...
  35. evaluate_retval start
  36. ;;
  37. stop)
  38. #killproc -TERM "${BIN_FILE}" or:
  39. endproc
  40. evaluate_retval stop
  41. ;;
  42. force-reload)
  43. reloadproc -force
  44. evaluate_retval force-reload
  45. ;;
  46. restart)
  47. $0 stop
  48. $0 start
  49. ;;
  50. status)
  51. statusproc
  52. ;;
  53. # reload and try-restart are optional per LSB requirements
  54. reload)
  55. reloadproc
  56. evaluate_retval reload
  57. ;;
  58. try-restart)
  59. # Since this is optional there is no lfs-function for this one...
  60. # might be at a later time if used enough, but I doubt it usefullness.
  61. pidofproc "${BIN_FILE}" > /dev/null
  62. if [ "${?}" -ne "0" ]; then
  63. MESSAGE="${MESSAGE}: Not Running"
  64. else
  65. $0 stop
  66. $0 start
  67. exit 0
  68. fi
  69. evaluate_retval try-restart
  70. ;;
  71. *)
  72. echo "Usage: ${0} {start|stop|{force-}reload|{try-}restart|status}"
  73. exit 1
  74. ;;
  75. esac
  76. # End $RC_BASE/init.d/template