Here's attached a patch to have user and group used under openSUSE/SLES init script.
Made against lastest 5.1 git. Should apply without modification on 5.0 Important notice : Previous script doesn't use uid or gid affected to bacula. So each already installed installation should check rights in the working directory, all libs & exec. Admins should also check the rights of the bacula-sd ( if disks backup based are used ) and add the bacula user to group disk & tape I've added a sysconfig.bacula.in template that can be provided. But I didn't know if it should be provide at this place nor with this form. Hope this help . -- Bruno Friedmann (irc:tigerfoot) Ioda-Net Sàrl www.ioda-net.ch openSUSE Member User www.ioda.net/r/osu Blog www.ioda.net/r/blog fsfe fellowship www.fsfe.org GPG KEY : D5C9B751C4653227 vcard : http://it.ioda-net.ch/ioda-net.vcf
From fb845c02baec7e08553a7a387c42bb96c1881432 Mon Sep 17 00:00:00 2001 From: Bruno Friedmann <br...@ioda-net.ch> Date: Sun, 26 Dec 2010 18:43:32 +0100 Subject: [PATCH] Changes in init script for openSUSE Add the usage like the RedHat ones of system wide config /etc/sysconfig/bacula (sysconfig.bacula.in can be used as a template) Add the option for correct group & user for each daemon This changes implies that final users, under openSUSE/SLES check the right to their working dir, disk based media backup. And if the rpm doesn't do that for them add bacula user to disk & tape group. Signed-off-by: Bruno Friedmann <br...@ioda-net.ch> --- bacula/platforms/suse/bacula-dir.in | 130 ++++++++++++++++++++-------- bacula/platforms/suse/bacula-fd.in | 123 +++++++++++++++++++-------- bacula/platforms/suse/bacula-sd.in | 125 +++++++++++++++++++-------- bacula/platforms/suse/sysconfig.bacula.in | 36 ++++++++ 4 files changed, 303 insertions(+), 111 deletions(-) create mode 100644 bacula/platforms/suse/sysconfig.bacula.in diff --git a/bacula/platforms/suse/bacula-dir.in b/bacula/platforms/suse/bacula-dir.in index 5402a0d..bf4db3d 100755 --- a/bacula/platforms/suse/bacula-dir.in +++ b/bacula/platforms/suse/bacula-dir.in @@ -1,7 +1,7 @@ #! /bin/sh # -# bacula This shell script takes care of starting and stopping -# the bacula Director daemon +# bacula This shell script takes care of starting and stopping +# bacula Director daemon # # chkconfig: 2345 90 9 # description: The Leading Open Source Backup Solution. @@ -10,13 +10,16 @@ # Modified to work on SuSE 1/31/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added rc.status functions 3/13/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added LSB init info 10/14/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> +# Adjusted require-start/stop Added system-wide prefs & user/ group call 12/27/2010 Bruno Friedmann <bruno at ioda-net.ch> # ### BEGIN INIT INFO -# Provides: bacula-dir -# Required-Start: $local_fs $network @DB_TYPE@ -# Required-Stop: $local_fs $network @DB_TYPE@ +# Provides: bacula-dir +# Required-Start: $local_fs $network $remote_fs +# Should-Start: $time mysql postgresql +# Required-Stop: $local_fs $network mysql $remote_fs +# Should-Stop: $time mysql postgresql # Default-Start: 3 5 -# Default-Stop: 0 1 2 6 +# Default-Stop: 0 1 2 6 # Short-Description: bacula director # Description: Bacula network backup system director daemon ### END INIT INFO @@ -25,37 +28,90 @@ # this gives us funtion rc_status -v to tell us if we succeed or fail . /etc/rc.status -RETVAL=0 +# +dir_us...@dir_user@ +dir_gro...@dir_group@ +DIR_OPTIONS='' + +# pull in any user defined DIR_DIR_OPTIONS, DIR_USER, or DIR_GROUP +[ -f /etc/sysconfig/bacula ] && . /etc/sysconfig/bacula + +if [ -z ${BACULA_DIR_BIN} ]; +then + echo "You have to check /etc/sysconfig/bacula" + exit 1 +fi + +test -x @sbindir@/bacula-dir || { echo "@sbindir@/bacula-dir not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + case "$1" in - start) - echo -n "Starting the Bacula Director: " - /sbin/startproc @sbindir@/bacula-dir $2 -c @sysconfdir@/bacula-dir.conf - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-dir - ;; - stop) - echo -n "Stopping the Director daemon: " - /sbin/killproc @sbindir@/bacula-dir - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-dir - ;; - restart) - $0 stop - sleep 5 - $0 start - ;; + start) + if [ "${DIR_USER}" != '' ]; then + DIR_OPTIONS="${DIR_OPTIONS} -u ${DIR_USER}" + fi + + if [ "${DIR_GROUP}" != '' ]; then + DIR_OPTIONS="${DIR_OPTIONS} -g ${DIR_GROUP}" + fi + echo -n "Starting Bacula Director daemon : " + /sbin/startproc -q @sbindir@/bacula-dir $2 ${DIR_OPTIONS} -c @sysconfdir@/bacula-dir.conf + RETVAL=$? + rc_status -v + echo + [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-dir + ;; + + stop) + echo -n "Stopping Bacula Director daemon : " + /sbin/killproc -TERM @sbindir@/bacula-dir + RETVAL=$? + rc_status -v + echo + [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-dir + ;; + + try-restart|condrestart) + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset + fi + rc_status + ;; + + restart) + $0 stop + sleep 5 + $0 start + rc_status -v + ;; + + force-reload) + $0 try-restart + rc_status -v + ;; + + reload) + rc_failed 3 + rc_status -v + ;; + status) - /sbin/checkproc @sbindir@/bacula-dir - RETVAL=$? - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|restart|status}" - exit 1 - ;; + echo -n "Checking for service Bacula Director daemon : " + /sbin/checkproc @sbindir@/bacula-dir + RETVAL=$? + rc_status -v + ;; + + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" + exit 1 + ;; esac -exit $RETVAL +rc_exit diff --git a/bacula/platforms/suse/bacula-fd.in b/bacula/platforms/suse/bacula-fd.in index c14dd2e..5a7cbbd 100755 --- a/bacula/platforms/suse/bacula-fd.in +++ b/bacula/platforms/suse/bacula-fd.in @@ -1,7 +1,7 @@ #! /bin/sh # -# bacula This shell script takes care of starting and stopping -# the bacula File daemon. +# bacula This shell script takes care of starting and stopping +# bacula File daemon. # # chkconfig: 2345 90 9 # description: The Leading Open Source Backup Solution. @@ -10,13 +10,14 @@ # Modified to work on SuSE 1/31/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added rc.status functions 3/13/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added LSB init info 10/14/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> +# Adjusted require-start/stop Added system-wide prefs & user/ group call 12/27/2010 Bruno Friedmann <bruno at ioda-net.ch> # ### BEGIN INIT INFO -# Provides: bacula-fd -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network +# Provides: bacula-fd +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs # Default-Start: 3 5 -# Default-Stop: 0 1 2 6 +# Default-Stop: 0 1 2 6 # Short-Description: bacula file daemon # Description: Bacula network backup system file daemon ### END INIT INFO @@ -25,36 +26,84 @@ # this gives us funtion rc_status -v to tell us if we succeed or fail . /etc/rc.status +fd_us...@fd_user@ +fd_gro...@fd_group@ +FD_OPTIONS='' + +# pull in any user defined FD_OPTIONS, FD_USER, FD_GROUP +[ -f /etc/sysconfig/bacula ] && . /etc/sysconfig/bacula + +test -x @sbindir@/bacula-fd || { echo "@sbindir@/bacula-fd not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + + case "$1" in - start) - echo -n "Starting the Bacula File daemon: " - /sbin/startproc @sbindir@/bacula-fd $2 -c @sysconfdir@/bacula-fd.conf - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-fd - ;; - stop) - echo -n "Stopping the Bacula File daemon: " - /sbin/killproc @sbindir@/bacula-fd - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-fd - ;; - restart) - $0 stop - sleep 5 - $0 start - ;; - status) - /sbin/checkproc @sbindir@/bacula-fd - RETVAL=$? - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|restart|status}" - exit 1 - ;; + start) + if [ "${FD_USER}" != '' ]; then + FD_OPTIONS="${FD_OPTIONS} -u ${FD_USER}" + fi + + if [ "${FD_GROUP}" != '' ]; then + FD_OPTIONS="${FD_OPTIONS} -g ${FD_GROUP}" + fi + echo -n "Starting Bacula File daemon : " + /sbin/startproc -q @sbindir@/bacula-fd $2 ${FD_OPTIONS} -c @sysconfdir@/bacula-fd.conf + RETVAL=$? + rc_status -v + echo + [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-fd + ;; + + stop) + echo -n "Stopping Bacula File daemon : " + /sbin/killproc -TERM @sbindir@/bacula-fd + RETVAL=$? + rc_status -v + echo + [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-fd + ;; + + try-restart|condrestart) + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset + fi + rc_status + ;; + + restart) + $0 stop + sleep 2 + $0 start + + rc_status + ;; + + force-reload) + $0 try-restart + rc_status + ;; + + reload) + rc_failed 3 + rc_status -v + ;; + + status) + echo -n "Checking service Bacula File daemon : " + checkproc @sbindir@/bacula-fd + rc_status -v + ;; + + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" + exit 1 + ;; esac -exit $RETVAL +rc_exit diff --git a/bacula/platforms/suse/bacula-sd.in b/bacula/platforms/suse/bacula-sd.in index d2b3afd..ac3bd8f 100755 --- a/bacula/platforms/suse/bacula-sd.in +++ b/bacula/platforms/suse/bacula-sd.in @@ -1,7 +1,7 @@ #! /bin/sh # -# bacula This shell script takes care of starting and stopping -# the bacula Storage daemon. +# bacula This shell script takes care of starting and stopping +# bacula Storage daemon. # # chkconfig: 2345 90 9 # description: The Leading Open Source Backup Solution. @@ -10,13 +10,16 @@ # Modified to work on SuSE 1/31/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added rc.status functions 3/13/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> # Added LSB init info 10/14/2004 D. Scott Barninger <barninger at fairfieldcomputers.com> +# Adjusted require-start/stop Added system-wide prefs & user/ group call 12/27/2010 Bruno Friedmann <bruno at ioda-net.ch> + + # ### BEGIN INIT INFO -# Provides: bacula-sd -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network +# Provides: bacula-sd +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs # Default-Start: 3 5 -# Default-Stop: 0 1 2 6 +# Default-Stop: 0 1 2 6 # Short-Description: bacula storage daemon # Description: Bacula network backup system storage daemon ### END INIT INFO @@ -25,36 +28,84 @@ # this gives us funtion rc_status -v to tell us if we succeed or fail . /etc/rc.status +sd_us...@sd_user@ +sd_gro...@sd_group@ +SD_OPTIONS='' + +# System wide configuration +[ -f /etc/sysconfig/bacula ] && . /etc/sysconfig/bacula + + +test -x @sbindir@/bacula-sd || { echo "@sbindir@/bacula-sd not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + case "$1" in - start) - echo -n "Starting the Bacula Storage daemon: " - /sbin/startproc @sbindir@/bacula-sd $2 -c @sysconfdir@/bacula-sd.conf - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-sd - ;; - stop) - echo -n "Stopping the Bacula Storage daemon: " - /sbin/killproc @sbindir@/bacula-sd - RETVAL=$? - rc_status -v - echo - [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-sd - ;; - restart) - $0 stop - sleep 5 - $0 start - ;; - status) - /sbin/checkproc @sbindir@/bacula-sd - RETVAL=$? - rc_status -v - ;; - *) - echo "Usage: $0 {start|stop|restart|status}" - exit 1 - ;; + start) + if [ "${SD_USER}" != '' ]; then + SD_OPTIONS="${SD_OPTIONS} -u ${SD_USER}" + fi + + if [ "${SD_GROUP}" != '' ]; then + SD_OPTIONS="${SD_OPTIONS} -g ${SD_GROUP}" + fi + + echo -n "Starting Bacula Storage daemon : " + /sbin/startproc -q @sbindir@/bacula-sd $2 ${SD_OPTIONS} -c @sysconfdir@/bacula-sd.conf + RETVAL=$? + rc_status -v + echo + [ $RETVAL -eq 0 ] && touch @subsysdir@/bacula-sd + ;; + + stop) + echo -n "Stopping Bacula Storage daemon : " + /sbin/killproc -TERM @sbindir@/bacula-sd + RETVAL=$? + rc-status -v + echo + [ $RETVAL -eq 0 ] && rm -f @subsysdir@/bacula-sd + ;; + + try-restart|condrestart) + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset + fi + rc_status + ;; + + restart) + $0 stop + sleep 5 + $0 start + rc_status + ;; + + force-reload) + $0 try-restart + rc_status + ;; + + reload) + rc_failed 3 + rc_status -v + ;; + + status) + echo -n "Checking for service Bacula Storage daemon : " + checkproc @sbindir@/bacula-sd + rc_status -v + ;; + + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" + exit 1 + ;; esac -exit $RETVAL +rc_exit diff --git a/bacula/platforms/suse/sysconfig.bacula.in b/bacula/platforms/suse/sysconfig.bacula.in new file mode 100644 index 0000000..8fc7894 --- /dev/null +++ b/bacula/platforms/suse/sysconfig.bacula.in @@ -0,0 +1,36 @@ +# +# bacula configuration read by init scripts +# openSUSE system wide configuration +# + +## bacula-dir +# Path to the director binary +DIR_BIN="@sbindir@/bacula-dir" +# Path to the director conf file +DIR_CONF="@sysconfigdir@/bacula-dir.conf" +# options passed to the director +# usually the uid & gid used +DIR_USER="bacula" +DIR_GROUP="bacula" + +## bacula-sd +# Path to the storage binary +SD_BIN="@sbindir@/bacula-sd" +# Path to the storage conf file +SD_CONF="@sysconfigdir@/bacula-sd.conf" +# options passed to the storage +# usually the uid & gid used +# on openSUSE & tape usage check that bacula user is +# also on group tapes +SD_USER="bacula" +SD_GROUP="disk" + +## bacula-fd +# Path to the file-daemon binary +FD_BIN="@sbindir@/bacula-fd" +# Path to the file-daemon conf file +FD_CONF="@sysconfigdir@/bacula-fd.conf" +# usually the uid & gid used +FD_USER="root" +FD_GROUP="bacula" + -- 1.7.3.4
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________ Bacula-devel mailing list Bacula-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-devel