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