3 # for Bacula on Slackware platform
4 # Phil Stracchino 13 Mar 2004
6 # Installs and removes Bacula install section into /etc/rc.d/rc.local
7 # provided /etc/rc.d/rc.local is writeable. Creates a backup copy of
8 # /etc/rc.d/rc.local in /etc/rc.d/rc.local.bak if /etc/rc.d is writeable.
10 # Usage: local-install.sh install|remove [destdir]
12 # uncomment for debugging:
16 TARG=$DESTDIR/etc/rc.d/rc.local
18 TARG=/etc/rc.d/rc.local
21 if [ ! -f $TARG ] ; then
22 echo $TARG does not appear to exist. Bailing out.
26 if [ "$1" = "install" ] ; then
27 echo Installing Bacula autostart into $TARG:
28 COUNT=`grep -c "Bacula section @@@@" $TARG`
29 if [ ! "$COUNT" == "0" ] ; then
30 echo -e "\tBacula autostart section appears to be already installed.\n\tIf you have changed the configuration, make uninstall-autostart\n\tthen make install-autostart again.\n"
32 if [ -w $TARG ] ; then
33 if [ -w `dirname $TARG` ] ; then
35 echo -e "\tBackup copy of $TARG saved in $TARG.bak."
37 echo -e "\tWARNING: Unable to create backup copy of $TARG.\n\tAttempting to continue anyway.";
40 # @@@@ Start Bacula section @@@@
41 # The line above is needed to automatically remove bacula.
43 if [ -x /etc/rc.d/rc.bacula-sd ]; then
44 /etc/rc.d/rc.bacula-sd start
46 if [ -x /etc/rc.d/rc.bacula-fd ]; then
47 /etc/rc.d/rc.bacula-fd start
49 if [ -x /etc/rc.d/rc.bacula-dir ]; then
50 /etc/rc.d/rc.bacula-dir start
53 # @@@@ End Bacula section @@@@
55 echo -e "\tBacula autostart section has been installed in $TARG.\n";
57 echo -e "\tERROR! Cannot write to $TARG.\n\tBailing out.\n"
61 elif [ "$1" = "remove" ] ; then
62 echo Removing Bacula autostart from $TARG:
63 COUNT=`grep -c "Bacula section @@@@" $TARG`
64 if [ ! "$COUNT" == "2" ] ; then
65 echo -e "\tCould not find Bacula autostart section in $TARG. Bailing out.\n"
68 if [ -w $TARG ] ; then
69 if [ -w `dirname $TARG` ] ; then
71 echo -e "\tBackup copy of $TARG saved in $TARG.bak."
73 echo -e "\tWARNING: Unable to create backup copy of $TARG.\n\tAttempting to continue anyway.";
75 FIRST=`grep -n "@@@@ Start Bacula section @@@@" $TARG | cut -d: -f1`
76 LAST=`grep -n "@@@@ End Bacula section @@@@" $TARG | cut -d: -f1`
77 FIRST=`expr $FIRST - 1`
79 head -$FIRST $TARG > ./installtmp
80 tail +$LAST $TARG >> ./installtmp
81 cat ./installtmp > $TARG
83 echo -e "\tBacula autostart section has been removed from $TARG.\n";
87 echo -e "\tUSAGE: $0 install|remove [destdir]"