]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/ubuntu/bacula-sd.in
Allow custom variables and checks from debian/ubuntu startup scripts
[bacula/bacula] / bacula / platforms / ubuntu / bacula-sd.in
1 #! /bin/sh
2 #
3 # bacula  This shell script takes care of starting and stopping
4 #         the bacula Director daemon on Debian/Ubuntu/Kubuntu 
5 #         systems. 
6 #
7 #   Kern E. Sibbald - 21 March 2008
8 #
9 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
10 #
11
12 ### BEGIN INIT INFO
13 # Provides:             bacula-sdr
14 # Required-Start:       $local_fs $remote_fs $network $time
15 # Required-Stop:        $local_fs $remote_fs $network $time
16 # Default-Start:        2 3 4 5
17 # Default-Stop:         0 1 6
18 # Short-Description:    Bacula Storage Daemon
19 # Description:          Bacula is a network backup and restore program
20 ### END INIT INFO
21
22
23 NAME="bacula-sd"
24 DESC="Bacula Storage Daemon"
25 DAEMON=@sbindir@/${NAME}
26 BUSER=@sd_user@
27 BGROUP=@sd_group@
28 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
29 BPORT=@sd_port@
30
31 PATH=/sbin:/bin:/usr/sbin:/usr/bin
32
33 test -f $DAEMON || exit 0
34
35 #
36 # Disable Glibc malloc checks, it doesn't help and it keeps from getting
37 #   good dumps
38 MALLOC_CHECK_=0
39 export MALLOC_CHECK_
40
41 if [ -n "`getent services ${NAME}`" ]; then
42    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
43 fi
44
45 if [ -f /etc/default/$NAME ]; then
46    . /etc/default/$NAME
47 fi
48
49 mkdir -p @piddir@
50 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
51
52 if [ "x${BUSER}" != "x" ]; then
53    USERGRP="--chuid ${BUSER}"
54    if [ "x${BGROUP}" != "x" ]; then
55       USERGRP="${USERGRP}:${BGROUP}"
56    fi
57 fi
58
59 case "$1" in
60    start)
61       echo -n "Starting ${DESC}: "
62       start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
63       RETVAL=$?
64       echo "${NAME}"
65       ;;
66    stop)
67       echo -n "Stopping ${DESC}: "
68       start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
69       RETVAL=$?
70       echo "${NAME}"
71       ;;
72    restart|force-reload)
73       $0 stop
74       sleep 5
75       $0 start
76       ;;
77    *)
78       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
79       exit 1
80       ;;
81 esac
82 exit $RETVAL