template 2.3 KB

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