]> git.sur5r.net Git - bacula/bacula/commitdiff
Make changes to slackware as requested by Phil
authorKern Sibbald <kern@sibbald.com>
Sat, 13 Mar 2004 17:57:44 +0000 (17:57 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 13 Mar 2004 17:57:44 +0000 (17:57 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1135 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/platforms/slackware/Makefile.in
bacula/platforms/slackware/local-install.sh [new file with mode: 0755]

index f4b86dace84e199f184efc98c4b50e7039f037c7..056b2705a72e7dfd16ce1d5ea08c8de208107ba3 100644 (file)
@@ -7,6 +7,8 @@
 #  Patrick Naubert 25 Jan 2003
 # and reworked for Slackware by
 #  Matt Howard 09 Mar 2004
+# further reworked for Slackware without Perl dependency by
+#  Phil Stracchino 13 Mar 2004
 #
 #  for Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
 #
@@ -31,7 +33,7 @@ install-autostart-dir: install-autostart-rc
 
 install-autostart-rc:
        @$(INSTALL) -m 744 functions.bacula $(DESTDIR)/etc/rc.d
-       ./add-remove-rc.local.pl -a $(DESTDIR)
+       sh ./local-install.sh install $(DESTDIR)
 
 
 uninstall: uninstall-autostart
@@ -49,7 +51,7 @@ uninstall-autostart-dir: uninstall-autostart-rc
 
 uninstall-autostart-rc:
        @rm -f $(DESTDIR)/etc/rc.d/functions.bacula
-       ./add-remove-rc.local.pl -r $(DESTDIR)
+       sh ./local-install.sh remove $(DESTDIR)
 
 
 clean:
diff --git a/bacula/platforms/slackware/local-install.sh b/bacula/platforms/slackware/local-install.sh
new file mode 100755 (executable)
index 0000000..68a17c1
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/sh
+# local-install.sh
+# for Bacula on Slackware platform
+# Phil Stracchino 13 Mar 2004
+#
+# Installs and removes Bacula install section into /etc/rc.d/rc.local
+# provided /etc/rc.d/rc.local is writeable.  Creates a backup copy of
+# /etc/rc.d/rc.local in /etc/rc.d/rc.local.bak if /etc/rc.d is writeable.
+#
+# Usage: local-install.sh install|remove [destdir]
+#
+# uncomment for debugging:
+#set -x
+
+if [ -n "$2" ] ; then
+   TARG=$DESTDIR/etc/rc.d/rc.local
+else
+   TARG=/etc/rc.d/rc.local
+fi
+
+if [ ! -f $TARG ] ; then
+   echo $TARG does not appear to exist.  Bailing out.
+   exit -1
+fi
+
+if [ "$1" = "install" ] ; then
+   echo Installing Bacula autostart into $TARG:
+   COUNT=`grep -c "Bacula section @@@@" $TARG`
+   if [ ! "$COUNT" == "0" ] ; then
+      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"
+   else
+      if [ -w $TARG ] ; then
+         if [ -w `dirname $TARG` ] ; then
+            cp -p $TARG $TARG.bak
+            echo -e "\tBackup copy of $TARG saved in $TARG.bak."
+         else
+            echo -e "\tWARNING: Unable to create backup copy of $TARG.\n\tAttempting to continue anyway.";
+         fi
+         cat >> $TARG << EOF
+# @@@@ Start Bacula section @@@@
+# The line above is needed to automatically remove bacula.
+
+if [ -x /etc/rc.d/rc.bacula-sd ]; then
+   /etc/rc.d/rc.bacula-sd start
+fi
+if [ -x /etc/rc.d/rc.bacula-fd ]; then
+   /etc/rc.d/rc.bacula-fd start
+fi
+if [ -x /etc/rc.d/rc.bacula-dir ]; then
+   /etc/rc.d/rc.bacula-dir start
+fi
+
+# @@@@ End Bacula section @@@@
+EOF
+         echo -e "\tBacula autostart section has been installed in $TARG.\n";
+      else
+         echo -e "\tERROR!  Cannot write to $TARG.\n\tBailing out.\n"
+         exit -1
+      fi
+   fi
+elif [ "$1" = "remove" ] ; then
+   echo Removing Bacula autostart from $TARG:
+   COUNT=`grep -c "Bacula section @@@@" $TARG`
+   if [ ! "$COUNT" == "2" ] ; then
+      echo -e "\tCould not find Bacula autostart section in $TARG.  Bailing out.\n"
+      exit -1
+   else
+      if [ -w $TARG ] ; then
+         if [ -w `dirname $TARG` ] ; then
+            cp -p $TARG $TARG.bak
+            echo -e "\tBackup copy of $TARG saved in $TARG.bak."
+         else
+            echo -e "\tWARNING: Unable to create backup copy of $TARG.\n\tAttempting to continue anyway.";
+         fi
+         FIRST=`grep -n "@@@@ Start Bacula section @@@@" $TARG | cut -d: -f1`
+         LAST=`grep -n "@@@@ End Bacula section @@@@" $TARG | cut -d: -f1`
+         FIRST=`expr $FIRST - 1`
+         LAST=`expr $LAST + 1`
+         head -$FIRST $TARG > ./installtmp
+         tail +$LAST $TARG >> ./installtmp
+         cat ./installtmp > $TARG
+         rm ./installtmp
+         echo -e "\tBacula autostart section has been removed from $TARG.\n";
+      fi
+   fi
+else
+   echo -e "\tUSAGE: $0 install|remove [destdir]"
+fi
+exit 0