]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/ubuntu/bacula-fd.in
kes Correctly detect Ubuntu systems, and add ubuntu platform directory.
[bacula/bacula] / bacula / platforms / ubuntu / bacula-fd.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 NAME="bacula-fd"
13 DESC="Bacula File Daemon"
14 DAEMON=@sbindir@/${NAME}
15 BUSER=@fd_user@
16 BGROUP=@fd_group@
17 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
18 BPORT=@fd_port@
19
20 PATH=/sbin:/bin:/usr/sbin:/usr/bin
21
22 test -f $DAEMON || exit 0
23
24 if [ -n "`getent services ${NAME}`" ]; then
25    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
26 fi
27
28 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
29
30 if [ "x${BUSER}" != "x" ]; then
31    BOPTIONS="${BOPTIONS} -u ${BUSER}"
32 fi
33 if [ "x${BGROUP}" != "x" ]; then
34    BOPTIONS="${BOPTIONS} -g ${BGROUP}"
35 fi
36
37 case "$1" in
38    start)
39       echo -n "Starting ${DESC}: "
40       start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- ${BOPTIONS}
41       echo "${NAME}"
42       ;;
43    stop)
44       echo -n "Stopping ${DESC}: "
45       start-stop-daemon --oknodo --stop --quiet --exec ${DAEMON} -- ${BOPTIONS}
46       echo "${NAME}"
47       ;;
48    restart|force-reload)
49       $0 stop
50       sleep 5
51       $0 start
52       ;;
53    *)
54       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
55       exit 1
56       ;;
57 esac
58 exit 0