]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/debian/bacula-sd.in
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / platforms / debian / bacula-sd.in
1 #! /bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5
6 # bacula  This shell script takes care of starting and stopping
7 #         the bacula Director daemon on Debian/Ubuntu/Kubuntu 
8 #         systems. 
9 #
10 #   Kern E. Sibbald - 21 March 2008
11 #
12 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
13 #
14 ### BEGIN INIT INFO
15 # Provides:          bacula-sd
16 # Required-Start:    $network
17 # Required-Stop:     $network
18 # Default-Start:     2 3 4 5
19 # Default-Stop:      0 1 6
20 # Short-Description: Start @BACULA@ Storage daemon at boot time
21 # Description:       Enable @BACULA@ Storage daemon.
22 ### END INIT INFO
23
24
25 NAME="bacula-sd"
26 DESC="@BACULA@ Storage Daemon"
27 DAEMON=@sbindir@/${NAME}
28 BUSER=@sd_user@
29 BGROUP=@sd_group@
30 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
31 BPORT=@sd_port@
32
33 PATH=/sbin:/bin:/usr/sbin:/usr/bin
34
35 test -f $DAEMON || exit 0
36
37 if [ -n "`getent services ${NAME}`" ]; then
38    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
39 fi
40
41 if [ -f /etc/default/$NAME ]; then
42    . /etc/default/$NAME
43 fi
44
45 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
46
47 if [ "x${BUSER}" != "x" ]; then
48    USERGRP="--chuid ${BUSER}"
49    if [ "x${BGROUP}" != "x" ]; then
50       USERGRP="${USERGRP}:${BGROUP}"
51    fi
52 fi
53
54 RETVAL=0
55 case "$1" in
56    start)
57       echo -n "Starting ${DESC}: "
58       start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
59       RETVAL=$?
60       echo "${NAME}"
61       ;;
62    stop)
63       echo -n "Stopping ${DESC}: "
64       start-stop-daemon --oknodo --stop --quiet ${USERGRP}  --exec ${DAEMON} -- ${BOPTIONS}
65       RETVAL=$?
66       echo "${NAME}"
67       ;;
68    restart|force-reload)
69       $0 stop
70       sleep 5
71       $0 start
72       RETVAL=$?
73       ;;
74    *)
75       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
76       exit 1
77       ;;
78 esac
79 exit $RETVAL