/
bareos-sd.in
88 lines (76 loc) · 2 KB
/
bareos-sd.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
81
82
83
84
85
86
87
88
#! /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-sdr
# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Bareos Storage Daemon
# Description: Bareos is a network backup and restore program
### END INIT INFO
NAME="bareos-sd"
DESC="Bareos Storage Daemon"
DAEMON=@sbindir@/${NAME}
BUSER=@sd_user@
BGROUP=@sd_group@
BOPTIONS="-c @sysconfdir@/${NAME}.conf"
BPORT=@sd_port@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
test -f $DAEMON || exit 0
#
# Disable Glibc malloc checks, it doesn't help and it keeps from getting
# good dumps
MALLOC_CHECK_=0
export MALLOC_CHECK_
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
mkdir -p @piddir@
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)
echo -n "Starting ${DESC}: "
start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
RETVAL=$?
echo "${NAME}"
;;
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