3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # bacula This shell script takes care of starting and stopping
9 # This is pretty much watered down version of the RedHat script
10 # that works on Solaris as well as Linux, but it won't work everywhere.
12 # Submitted by Volker Sauer <volker@volker-sauer.de> 21Feb04
13 # Tweaked a bit by Kern to convert it to a .in file
15 # description: The Leading Open Source Backup Solution.
19 # Required-Start: network mysql
23 # Description: run bacula daemon(s)
30 # A function to stop a program.
35 echo "Usage: killproc {program} [signal]"
40 # check for third arg to be kill level
41 if [ "$3" != "" ] ; then
48 # Get base program name
52 pid=`pidofproc $base $2`
55 if [ "$pid" != "" ] ; then
56 if [ "$notset" = "1" ] ; then
57 if ps -p $pid>/dev/null 2>&1; then
58 # TERM first, then KILL if not dead
59 kill -TERM $pid 2>/dev/null
61 if ps -p $pid >/dev/null 2>&1 ; then
63 if ps -p $pid >/dev/null 2>&1 ; then
65 if ps -p $pid >/dev/null 2>&1 ; then
66 kill -KILL $pid 2>/dev/null
71 ps -p $pid >/dev/null 2>&1
73 [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
75 # use specified level only
77 if ps -p $pid >/dev/null 2>&1; then
78 kill $killlevel $pid 2>/dev/null
80 [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
84 failure "$base shutdown"
86 # Remove pid file if any.
87 if [ "$notset" = "1" ]; then
88 rm -f ${PIDDIR}/$base.$2.pid
93 # A function to find the pid of a program.
98 echo "Usage: pidofproc {program}"
102 # Get base program name
106 if [ -f ${PIDDIR}/$base.$2.pid ] ; then
107 pid=`head -1 ${PIDDIR}/$base.$2.pid`
108 if [ "$pid" != "" ] ; then
115 if [ -x /sbin/pidof ] ; then
118 if [ "$pid" != "" ] ; then
123 # Finally try to extract it from ps
124 ${PSCMD} | grep $1 | awk '{ print $1 }' | tr '\n' ' '
131 echo "Usage: status {program}"
135 # Get base program name
139 if [ -x /sbin/pidof ] ; then
142 if [ "$pid" != "" ] ; then
143 echo "$base (pid $pid) is running..."
146 pid=`${PSCMD} | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
147 { if ((prog == $2) || (("(" prog ")") == $2) ||
148 (("[" prog "]") == $2) ||
149 ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
150 if [ "$pid" != "" ] ; then
151 echo "$base (pid $pid) is running..."
156 # Next try the PID files
157 if [ -f ${PIDDIR}/$base.$2.pid ] ; then
158 pid=`head -1 ${PIDDIR}/$base.$2.pid`
159 if [ "$pid" != "" ] ; then
160 echo "$base not running, but pid file exists"
164 # See if the subsys lock exists
165 if [ -f ${SUBSYSDIR}/$base ] ; then
166 echo "$base not running, but subsys locked"
169 echo "$base is stopped"
184 echo "Starting the Storage daemon"
185 @sbindir@/bacula-sd $2 -v -c @sysconfdir@//bacula-sd.conf
186 echo "Starting the File daemon"
187 @sbindir@/bacula-fd $2 -v -c @sysconfdir@//bacula-fd.conf
189 echo "Starting the Director daemon"
190 @sbindir@/bacula-dir $2 -v -c @sysconfdir@//bacula-dir.conf
193 echo "Stopping the File daemon"
194 killproc @sbindir@/bacula-fd 9102
195 echo "Stopping the Storage daemon"
196 killproc @sbindir@/bacula-sd 9103
197 echo "Stopping the Director daemon"
198 killproc @sbindir@/bacula-dir 9101
207 status @sbindir@/bacula-sd 9103
208 status @sbindir@/bacula-fd 9102
209 status @sbindir@/bacula-dir 9101
212 echo "Usage: $0 {start|stop|restart|status}"