]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/hurd/bacula-sd.in
Backport from Bacula Enterprise
[bacula/bacula] / bacula / platforms / hurd / 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 GNU Hurd systems.
8 #
9 #   Kern E. Sibbald - 21 March 2008
10 #
11 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
12 #
13 ### BEGIN INIT INFO
14 # Provides:          bacula-sd
15 # Required-Start:    $network
16 # Required-Stop:     $network
17 # Default-Start:     2 3 4 5
18 # Default-Stop:      0 1 6
19 # Short-Description: Start @BACULA@ Storage daemon at boot time
20 # Description:       Enable @BACULA@ Storage daemon.
21 ### END INIT INFO
22
23
24 NAME="bacula-sd"
25 DESC="@BACULA@ Storage Daemon"
26 DAEMON=@sbindir@/${NAME}
27 BUSER=@sd_user@
28 BGROUP=@sd_group@
29 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
30 BPORT=@sd_port@
31
32 PATH=/sbin:/bin:/usr/sbin:/usr/bin
33
34 test -f $DAEMON || exit 0
35
36 if [ -n "`getent services ${NAME}`" ]; then
37    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
38 fi
39
40 if [ -f /etc/default/$NAME ]; then
41    . /etc/default/$NAME
42 fi
43
44 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
45
46 if [ "x${BUSER}" != "x" ]; then
47    USERGRP="--chuid ${BUSER}"
48    if [ "x${BGROUP}" != "x" ]; then
49       USERGRP="${USERGRP}:${BGROUP}"
50    fi
51 fi
52
53 RETVAL=0
54 case "$1" in
55    start)
56       echo -n "Starting ${DESC}: "
57       start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
58       RETVAL=$?
59       echo "${NAME}"
60       ;;
61    stop)
62       echo -n "Stopping ${DESC}: "
63       start-stop-daemon --oknodo --stop --quiet ${USERGRP}  --exec ${DAEMON} -- ${BOPTIONS}
64       RETVAL=$?
65       echo "${NAME}"
66       ;;
67    restart|force-reload)
68       $0 stop
69       sleep 5
70       $0 start
71       RETVAL=$?
72       ;;
73    *)
74       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
75       exit 1
76       ;;
77 esac
78 exit $RETVAL