aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts/contrib/lsb-v3/init.d/template
blob: cb3222a35487b6460fd54afa3477cd424fc2d137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# Begin /etc/init.d/template

### BEGIN INIT INFO
# Provides:            template
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description:
# Description: 
# X-LFS-Provided-By:
### END INIT INFO

# Source the LSB init-functions, ours are pulled in from there.
. /lib/lsb/init-functions

# These are optional, but required for chk_stat.  They will be used in 
# the rest of the functions if defined, else you must provide a program
# name to control, and a message ('Starting Template Service...' 
# or 'Stoping Template Service...') to evauate_retval.  See the 
# documentaion in the lfs-fucntions file for more information.
MESSAGE="Template Service"
BIN_FILE="/some/path/to/template"
CONFIGFILE="/etc/sysconfig/template.conf"

# check that $BIN_FILE exists and is executable, and $CONFIGFILE exists.
chk_stat

# LSB Defined functions require that at least $BIN_FILE be passed to them,
# where as lfs-functions will use the $BIN_FILE environment variable.
# loadproc() and endproc() are just wrappers that pass everything on to 
# the LSB defined functions.

case "${1}" in
    start)
        #start_daemon "${BIN_FILE}" -arg1 -arg2 #... or:
        loadproc -arg1 -arg2 -arg3 #...
        evaluate_retval start
        ;;

    stop)
        #killproc -TERM "${BIN_FILE}" or:
        endproc
        evaluate_retval stop
        ;;

    force-reload)
        reloadproc -force
        evaluate_retval force-reload
        ;;

    restart)
        $0 stop
        $0 start
        ;;

    status)
        statusproc
        ;;

# reload and try-restart are optional per LSB requirements
    reload)
        reloadproc
        evaluate_retval reload
        ;;

    try-restart)
	# Since this is optional there is no lfs-function for this one...
        # might be at a later time if used enough, but I doubt it usefullness.
        pidofproc "${BIN_FILE}" > /dev/null
        if [ "${?}" -ne "0" ]; then
            MESSAGE="${MESSAGE}: Not Running"
        else
            $0 stop
            $0 start
            exit 0
        fi
        evaluate_retval try-restart
        ;;

    *)
        echo "Usage: ${0} {start|stop|{force-}reload|{try-}restart|status}"
        exit 1
        ;;
esac

# End /etc/init.d/template