Update SysV init scripts

This commit is contained in:
Simone Caronni 2013-01-09 12:55:32 +01:00
parent 115b75c31c
commit dd59afd339
4 changed files with 261 additions and 173 deletions

View File

@ -1,87 +1,116 @@
#!/bin/bash #!/bin/sh
# #
# bacula-dir This shell script takes care of starting and stopping # bacula-dir Takes care of starting and stopping the Bacula Director.
# the bacula-dir daemon, the backup director controling
# the backup jobs.
# #
# chkconfig: - 80 20 # chkconfig: - 80 20
# description: Bacula-dir is the Backup-server, which is the program \ # description: The Bacula Director is the daemon responsible for all the logic \
# that schedules backups and controls the bacula-client and \ # regarding the backup infrastructure: database, file retention, \
# the bacula-storage daemons. # tape indexing, scheduling.
# processname: bacula-dir
# config: /etc/bacula/bacula-dir.conf ### BEGIN INIT INFO
# pidfile: /var/run/bacula-dir.9101.pid # Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Bacula Director Daemon.
# Description: The Bacula Director is the daemon responsible for all the logic
# regarding the backup infrastructure: database, file retention,
# tape indexing, scheduling.
### END INIT INFO
# Source function library. # Source function library.
. /etc/init.d/functions . /etc/rc.d/init.d/functions
# Source configuration. exec="/usr/sbin/bacula-dir"
if [ -f /etc/sysconfig/bacula-dir ] ; then
. /etc/sysconfig/bacula-dir
fi
RETVAL=0
prog="bacula-dir" prog="bacula-dir"
CONFIG="/etc/bacula/bacula-dir.conf" CONFIG="/etc/bacula/bacula-dir.conf"
OPTS="-c $CONFIG" OPTS="-c $CONFIG"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
if [ "$DIR_USER" != '' ]; then if [ "$DIR_USER" != '' ]; then
OPTS="$OPTS -u $DIR_USER" OPTS="$OPTS -u $DIR_USER"
fi fi
if [ "$DIR_GROUP" != '' ]; then if [ "$DIR_GROUP" != '' ]; then
OPTS="$OPTS -g $DIR_GROUP" OPTS="$OPTS -g $DIR_GROUP"
fi fi
start() { start() {
[ "$EUID" != "0" ] && exit 4 [ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n "Starting $prog: " echo -n $"Starting $prog: "
bacula-checkconf $CONFIG bacula-checkconf $CONFIG
daemon $prog $OPTS daemon $prog $OPTS
RETVAL=$? retval=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog [ $retval -eq 0 ] && touch $lockfile
return $RETVAL return $retval
} }
stop() { stop() {
[ "$EUID" != "0" ] && exit 4 echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
echo -n "Shutting down $prog: " retval=$?
killproc $prog echo
RETVAL=$? [ $retval -eq 0 ] && rm -f $lockfile
echo return $retval
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
} }
restart() {
stop
sleep 1
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in case "$1" in
start) start)
start rh_status_q && exit 0
;; $1
;;
stop) stop)
stop rh_status_q || exit 0
;; $1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status) status)
status $prog rh_status
;; ;;
restart|force-reload)
stop
sleep 1
start
;;
condrestart|try-restart) condrestart|try-restart)
if [ -f /var/lock/subsys/$prog ]; then rh_status_q || exit 0
stop restart
sleep 1 ;;
start
fi
;;
*) *)
echo "Usage: $prog {start|stop|status|restart|force-reload|condrestart|try-restart}" echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
[ "$1" = "usage" ] && exit 0 exit 2
exit 2
;;
esac esac
exit $? exit $?

View File

@ -1,87 +1,114 @@
#!/bin/bash #!/bin/sh
# #
# bacula-fd This shell script takes care of starting and stopping # bacula-fd Takes care of starting and stopping the Bacula File Daemon.
# the bacula-fd daemon, the backup client enabling bacula
# to backup the local machine.
# #
# chkconfig: - 80 20 # chkconfig: - 80 20
# description: Bacula-fd is a Backup-client, which is the program \ # description: The Bacula File Daemon is the daemon responsible for backing up \
# that enables the bacula-server to backup the local \ # data on the system.
# machine.
# processname: bacula-fd ### BEGIN INIT INFO
# config: /etc/bacula/bacula-fd.conf # Required-Start: $local_fs $network
# pidfile: /var/run/bacula-fd.9102.pid # Required-Stop: $local_fs $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Bacula File Daemon.
# Description: The Bacula File Daemon is the daemon responsible for backing up
# data on the system.
### END INIT INFO
# Source function library. # Source function library.
. /etc/init.d/functions . /etc/rc.d/init.d/functions
# Source configuration. exec="/usr/sbin/bacula-fd"
if [ -f /etc/sysconfig/bacula-fd ] ; then
. /etc/sysconfig/bacula-fd
fi
RETVAL=0
prog="bacula-fd" prog="bacula-fd"
CONFIG="/etc/bacula/bacula-fd.conf" CONFIG="/etc/bacula/bacula-fd.conf"
OPTS="-c $CONFIG" OPTS="-c $CONFIG"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog
if [ "$FD_USER" != '' ]; then if [ "$FD_USER" != '' ]; then
OPTS="$OPTS -u $FD_USER" OPTS="$OPTS -u $FD_USER"
fi fi
if [ "$FD_GROUP" != '' ]; then if [ "$FD_GROUP" != '' ]; then
OPTS="$OPTS -g $FD_GROUP" OPTS="$OPTS -g $FD_GROUP"
fi fi
start() { start() {
[ "$EUID" != "0" ] && exit 4 [ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n "Starting $prog: " echo -n $"Starting $prog: "
bacula-checkconf $CONFIG bacula-checkconf $CONFIG
daemon $prog $OPTS daemon $prog $OPTS
RETVAL=$? retval=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog [ $retval -eq 0 ] && touch $lockfile
return $RETVAL return $retval
} }
stop() { stop() {
[ "$EUID" != "0" ] && exit 4 echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
echo -n "Shutting down $prog: " retval=$?
killproc $prog echo
RETVAL=$? [ $retval -eq 0 ] && rm -f $lockfile
echo return $retval
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
} }
restart() {
stop
sleep 1
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in case "$1" in
start) start)
start rh_status_q && exit 0
;; $1
;;
stop) stop)
stop rh_status_q || exit 0
;; $1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status) status)
status $prog rh_status
;; ;;
restart|force-reload)
stop
sleep 1
start
;;
condrestart|try-restart) condrestart|try-restart)
if [ -f /var/lock/subsys/$prog ]; then rh_status_q || exit 0
stop restart
sleep 1 ;;
start
fi
;;
*) *)
echo "Usage: $prog {start|stop|status|restart|force-reload|condrestart|try-restart}" echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
[ "$1" = "usage" ] && exit 0 exit 2
exit 2
;;
esac esac
exit $? exit $?

View File

@ -1,86 +1,114 @@
#!/bin/bash #!/bin/sh
# #
# bacula-sd This shell script takes care of starting and stopping # bacula-sd Takes care of starting and stopping the Bacula Storage Daemon.
# the bacula-sd daemon, the storage daemon responsible
# for accessing the backup storage device.
# #
# chkconfig: - 80 20 # chkconfig: - 80 20
# description: Bacula-sd is the storage-server, which is the program \ # description: The Bacula Storage Daemon is the daemon responsible for saving \
# that accesses the storage device. # backed up data on the various File Daemon to the appropriate \
# processname: bacula-sd # storage devices.
# config: /etc/bacula/bacula-sd.conf
# pidfile: /var/run/bacula-dir.9103.pid ### BEGIN INIT INFO
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Bacula Storage Daemon.
# Description: The Bacula Storage Daemon is the daemon responsible for saving
# backed up data on the various File Daemon to the appropriate
# storage devices.
### END INIT INFO
# Source function library. # Source function library.
. /etc/init.d/functions . /etc/init.d/functions
# Source configuration. exec="/usr/sbin/bacula-sd"
if [ -f /etc/sysconfig/bacula-sd ] ; then
. /etc/sysconfig/bacula-sd
fi
RETVAL=0
prog="bacula-sd" prog="bacula-sd"
CONFIG="/etc/bacula/bacula-sd.conf" CONFIG="/etc/bacula/bacula-sd.conf"
OPTS="-c $CONFIG" OPTS="-c $CONFIG"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
if [ "$SD_USER" != '' ]; then if [ "$SD_USER" != '' ]; then
OPTS="$OPTS -u $SD_USER" OPTS="$OPTS -u $SD_USER"
fi fi
if [ "$SD_GROUP" != '' ]; then if [ "$SD_GROUP" != '' ]; then
OPTS="$OPTS -g $SD_GROUP" OPTS="$OPTS -g $SD_GROUP"
fi fi
start() { start() {
[ "$EUID" != "0" ] && exit 4 [ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n "Starting $prog: " echo -n $"Starting $prog: "
bacula-checkconf $CONFIG bacula-checkconf $CONFIG
daemon $prog $OPTS daemon $prog $OPTS
RETVAL=$? retval=$?
echo echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog [ $retval -eq 0 ] && touch $lockfile
return $RETVAL return $retval
} }
stop() { stop() {
[ "$EUID" != "0" ] && exit 4 echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
echo -n "Shutting down $prog: " retval=$?
killproc $prog echo
RETVAL=$? [ $retval -eq 0 ] && rm -f $lockfile
echo return $retval
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
} }
restart() {
stop
sleep 2
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in case "$1" in
start) start)
start rh_status_q && exit 0
;; $1
;;
stop) stop)
stop rh_status_q || exit 0
;; $1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status) status)
status $prog rh_status
;; ;;
restart|force-reload)
stop
sleep 2
start
;;
condrestart|try-restart) condrestart|try-restart)
if [ -f /var/lock/subsys/$prog ]; then rh_status_q || exit 0
stop restart
sleep 2 ;;
start
fi
;;
*) *)
echo "Usage: $prog {start|stop|status|restart|force-reload|condrestart|try-restart}" echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
[ "$1" = "usage" ] && exit 0 exit 2
exit 2
;;
esac esac
exit $? exit $?

View File

@ -3,7 +3,7 @@
Name: bacula Name: bacula
Version: 5.2.12 Version: 5.2.12
Release: 3%{?dist} Release: 4%{?dist}
Summary: Cross platform network backup for Linux, Unix, Mac and Windows Summary: Cross platform network backup for Linux, Unix, Mac and Windows
# See LICENSE for details # See LICENSE for details
License: AGPLv3 with exceptions License: AGPLv3 with exceptions
@ -903,6 +903,10 @@ fi
%changelog %changelog
* Wed Jan 09 2013 Simone Caronni <negativo17@gmail.com> - 5.2.12-4
- Updated SysV init script according to Fedora template:
https://fedoraproject.org/wiki/Packaging:SysVInitScript
* Wed Oct 17 2012 Simone Caronni <negativo17@gmail.com> - 5.2.12-3 * Wed Oct 17 2012 Simone Caronni <negativo17@gmail.com> - 5.2.12-3
- Add sample-query.sql file to Director's docs. - Add sample-query.sql file to Director's docs.