]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/template.init
- more chkconfig vars
[projects/rc-scripts.git] / rc.d / init.d / template.init
1 #!/bin/sh
2 #
3 # <service>     <service> short service description
4 #
5 # chkconfig:    345 <start_level> <stop_level>
6 #
7 # description:  <service> long service description
8 #
9 # processname:  <service>
10 # config:
11 # pidfile:
12 #
13 # $Id$
14
15 # Source function library
16 . /etc/rc.d/init.d/functions
17
18 # Get network config
19 . /etc/sysconfig/network
20
21 # Set defaults
22 OPTION1=""      # Strings
23 OPTION2="-q"    #
24 OPTION3=        # Values
25 OPTION4=5       #
26
27 # Get service config - may override defaults
28 [ -f /etc/sysconfig/<service> ] && . /etc/sysconfig/<service>
29
30 # Check that networking is up.
31 if is_yes "${NETWORKING}"; then
32         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
33                 msg_network_down <service>
34                 exit 1
35         fi
36 else
37         exit 0
38 fi
39
40 start() {
41         # Check if the service is already running?
42         if [ ! -f /var/lock/subsys/<service> ]; then
43                 msg_starting <service>
44                 daemon /usr/sbin/<service>
45                 RETVAL=$?
46                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/<service>
47         else
48                 msg_already_running <service>
49         fi
50 }
51
52 stop() {
53         if [ -f /var/lock/subsys/<service> ]; then
54                 # Stop daemons.
55                 msg_stopping <service>
56                 killproc <service>
57                 killproc --pidfile /var/run/<service>.pid <service> -TERM
58                 rm -f /var/lock/subsys/<service>
59         else
60                 msg_not_running <service>
61         fi
62 }
63
64 reload() {
65         if [ -f /var/lock/subsys/<service> ]; then
66                 msg_reloading <service>
67                 killproc <service> -HUP
68                 killproc --pidfile /var/run/<service>.pid <service> -HUP
69                 RETVAL=$?
70         else
71                 msg_not_running <service>
72                 RETVAL=7
73         fi
74 }
75
76 condrestart() {
77         if [ -f /var/lock/subsys/<service> ]; then
78                 stop
79                 start
80         else
81                 msg_not_running <service>
82                 RETVAL=$1
83         fi
84 }
85
86 RETVAL=0
87 # See how we were called.
88 case "$1" in
89   start)
90         start
91         ;;
92   stop)
93         stop
94         ;;
95   restart)
96         stop
97         start
98         ;;
99   try-restart)
100         condrestart 0
101         ;;
102 # include force-reload here if program allows reloading without restart
103 # otherwise remove reload action and support force-reload as restart if running
104   reload|force-reload)
105         reload
106         ;;
107 # use this one if program doesn't support reloading without restart
108   force-reload)
109         condrestart 7
110         ;;
111   status)
112         status <service>
113         RETVAL=$?
114         ;;
115   *)
116         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
117         exit 3
118 esac
119
120 exit $RETVAL
This page took 0.035559 seconds and 4 git commands to generate.