/
bareos-dir.in
80 lines (71 loc) · 1.85 KB
/
bareos-dir.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
#
# bareos This shell script takes care of starting and stopping
# the bareos Director daemon on Debian/Ubuntu/Kubuntu
# systems.
#
# Kern E. Sibbald - 21 March 2008
#
# For Bareos release @VERSION@ (@DATE@) -- @DISTNAME@
#
### BEGIN INIT INFO
# Provides: bareos-dir
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start @BAREOS@ Director daemon at boot time
# Description: Enable @BAREOS@ Director.
### END INIT INFO
#
NAME="bareos-dir"
DESC="@BAREOS@ Director"
DAEMON=@sbindir@/${NAME}
BUSER=@dir_user@
BGROUP=@dir_group@
BOPTIONS="-c @sysconfdir@/${NAME}.conf"
BPORT=@dir_port@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
test -f $DAEMON || exit 0
if [ -n "`getent services ${NAME}`" ]; then
BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
fi
if [ -f /etc/default/$NAME ]; then
. /etc/default/$NAME
fi
PIDFILE=@piddir@/${NAME}.${BPORT}.pid
if [ "x${BUSER}" != "x" ]; then
USERGRP="--chuid ${BUSER}"
if [ "x${BGROUP}" != "x" ]; then
USERGRP="${USERGRP}:${BGROUP}"
fi
fi
# define LSB functions.
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
log_end_msg $?
sleep 2
;;
stop)
echo -n "Stopping ${DESC}: "
start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
RETVAL=$?
echo "${NAME}"
;;
restart|force-reload)
$0 stop
sleep 5
$0 start
;;
status)
status_of_proc -p ${PIDFILE} ${DAEMON} ${NAME} && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit $RETVAL