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