updated database_cleanup.sh
authorArt Cancro <ajc@citadel.org>
Tue, 30 Mar 2021 18:54:26 +0000 (14:54 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 30 Mar 2021 18:54:26 +0000 (14:54 -0400)
citadel/.gitignore
citadel/Makefile.in
citadel/configure.ac
citadel/database_cleanup.sh [new file with mode: 0755]
citadel/database_cleanup.sh.in [deleted file]

index 81bb5c3..7f78ac6 100644 (file)
@@ -22,7 +22,6 @@ config.status
 configure
 configure-stamp
 ctdlmigrate
-database_cleanup.sh
 getmail
 modules_init.c
 modules_init.h
index 1a49232..bf475da 100644 (file)
@@ -300,7 +300,7 @@ clean:
        rm -vf $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) $(NOINST_TARGETS)
 
 cleaner: clean
-       rm -vrf $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) $(NOINST_TARGETS) database_cleanup.sh *.la
+       rm -vrf $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) $(NOINST_TARGETS) *.la
        rm -vrf modules_upgrade.c modules_init.c modules_init.h Make_modules Make_sources
 
 distclean: cleaner
index 1c7d7ae..8320a9d 100644 (file)
@@ -918,7 +918,7 @@ AC_SUBST(SETUP_LIBS)
 AC_SUBST(DIFF)
 AC_SUBST(PATCH)
 AC_CONFIG_FILES([Makefile])
-AC_OUTPUT(database_cleanup.sh po/citadel-setup/Makefile)
+AC_OUTPUT(po/citadel-setup/Makefile)
 
 if test -z "$DATABASE"; then
        AC_MSG_WARN([No database driver was found. Please install Berkeley DB.])
diff --git a/citadel/database_cleanup.sh b/citadel/database_cleanup.sh
new file mode 100755 (executable)
index 0000000..c355274
--- /dev/null
@@ -0,0 +1,160 @@
+#!/bin/bash
+
+die () {
+       echo Exiting.
+       exit 1
+}
+
+DATA_DIR="/usr/local/citadel"
+
+usage() {
+       echo "Usage: database_cleanup.sh [ -h citadel_dir ]"
+       exit 2
+}
+
+PARSED_ARGUMENTS=$(getopt -a -n database_cleanup.sh -o h: -- "$@")
+VALID_ARGUMENTS=$?
+if [ "$VALID_ARGUMENTS" != "0" ]; then
+       usage
+fi
+
+eval set -- "$PARSED_ARGUMENTS"
+while :
+do
+       case "$1" in
+               -h | --alpha)
+                       DATA_DIR=${2}
+                       shift 2
+                       ;;
+               # -- means the end of the arguments; drop this, and break out of the while loop
+               --) shift; break ;;
+               # If invalid options were passed, then getopt should have reported an error,
+               # which we checked as VALID_ARGUMENTS when getopt was called...
+               *) echo "Unexpected option: $1 - this should not happen."
+                       usage
+                       ;;
+       esac
+done
+
+DATA_DIR=$DATA_DIR/data
+
+# If we're on an AppDir system, use the embedded db_tools.
+if [ "${APPDIR}" != "" ] ; then
+       export PATH=${APPDIR}/usr/bin:$PATH
+       RECOVER=${APPDIR}/usr/bin/db_recover
+       DUMP=${APPDIR}/usr/bin/db_dump
+       LOAD=${APPDIR}/usr/bin/db_load
+
+# If we're on an Easy Install system, use our own db_ tools.
+elif [ -x /usr/local/ctdlsupport/bin/db_dump ] ; then
+       export PATH=/usr/local/ctdlsupport/bin:$PATH
+       RECOVER=/usr/local/ctdlsupport/bin/db_recover
+       DUMP=/usr/local/ctdlsupport/bin/db_dump
+       LOAD=/usr/local/ctdlsupport/bin/db_load
+
+# usual install
+else
+       if test -f /usr/bin/db_dump; then 
+               RECOVER=/usr/bin/db_recover
+               DUMP=/usr/bin/db_dump
+               LOAD=/usr/bin/db_load
+       else
+               if test -n "`ls /usr/bin/db?*recover`"; then
+                       # seems we have something debian alike thats adding version in the filename
+                       if test "`ls /usr/bin/db*recover |wc -l`" -gt "1"; then 
+                               echo "Warning: you have more than one version of the Berkeley DB utilities installed." 1>&2
+                               echo "Using the latest one." 1>&2
+                               RECOVER=`ls /usr/bin/db*recover |sort |tail -n 1`
+                               DUMP=`ls /usr/bin/db*dump |sort |tail -n 1`
+                               LOAD=`ls /usr/bin/db*load |sort |tail -n 1`
+                       else
+                               RECOVER=`ls /usr/bin/db*recover`
+                               DUMP=`ls /usr/bin/db*dump`
+                               LOAD=`ls /usr/bin/db*load`
+                       fi
+               else
+                       echo "database_cleanup.sh cannot find the Berkeley DB utilities.  Exiting." 1>&2
+                       die
+               fi
+
+       fi
+fi
+
+# Ok, let's begin.
+
+clear
+cat <<!
+
+Citadel Database Cleanup
+---------------------------
+
+This script exports, deletes, and re-imports your database.  If you have
+any data corruption issues, this program may be able to clean them up for you.
+Please note that this program does a Berkeley DB dump/load, not a Citadel
+export.  The export files are not generated by the Citadel export module.
+
+WARNING #1:
+  MAKE A BACKUP OF YOUR DATA BEFORE ATTEMPTING THIS.  There is no guarantee
+  that this will work (in case of disk full, power failure, program crash)!
+
+WARNING #2:
+  citserver must NOT be running while you do this.
+
+WARNING #3:
+  Please try "cd $DATA_DIR; $RECOVER -c" first. Run citserver afterwards to 
+  revalidate whether its fixed or not, No news might be good news. Use this
+  tool only if that one fails to fix your problem.
+
+WARNING #4:
+  You must have an amount of free space on your disk that is at least twice
+  the size of your database, see the following output:
+  (for substantially better performance you should specify a location that is 
+   on another disk than $DATA_DIR)
+
+`df -h`
+
+you will need `du -sh $DATA_DIR|sed "s;/.*;;"` of free space.
+
+!
+
+echo We will attempt to look for a Citadel database in $DATA_DIR
+echo -n "Do you want to continue? "
+
+read yesno
+case "$yesno" in
+       "y" | "Y" | "yes" | "YES" | "Yes" )
+               echo 
+               echo DO NOT INTERRUPT THIS PROCESS.
+               echo
+       ;;
+       * )
+               exit
+esac
+
+for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
+do
+       filename=cdb.$x
+       echo Dumping $filename
+       $DUMP -h $DATA_DIR $filename >/tmp/CitaDump.$x || {
+               echo error $?
+               die
+       }
+       rm -f $DATA_DIR/$filename
+done
+
+echo Removing old databases
+rm -f ./data/*
+
+for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
+do
+       filename=cdb.$x
+       echo Loading $filename
+       $LOAD -h $DATA_DIR $filename </tmp/CitaDump.$x && {
+               rm -f /tmp/CitaDump.$x
+       }
+done
+
+echo 
+echo Dump/load operation complete.  Start your Citadel server now.
+echo
diff --git a/citadel/database_cleanup.sh.in b/citadel/database_cleanup.sh.in
deleted file mode 100755 (executable)
index e281549..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/bin/bash
-
-die () {
-       echo Exiting.
-       exit 1
-}
-
-DATA_DIR="/usr/local/citadel"
-
-
-
-usage() {
-       echo "Usage: database_cleanup.sh [ -h citadel_dir ]"
-       exit 2
-}
-
-PARSED_ARGUMENTS=$(getopt -a -n database_cleanup.sh -o h: -- "$@")
-VALID_ARGUMENTS=$?
-if [ "$VALID_ARGUMENTS" != "0" ]; then
-       usage
-fi
-
-eval set -- "$PARSED_ARGUMENTS"
-while :
-do
-       case "$1" in
-               -h | --alpha)
-                       DATA_DIR=${2}
-                       shift 2
-                       ;;
-               # -- means the end of the arguments; drop this, and break out of the while loop
-               --) shift; break ;;
-               # If invalid options were passed, then getopt should have reported an error,
-               # which we checked as VALID_ARGUMENTS when getopt was called...
-               *) echo "Unexpected option: $1 - this should not happen."
-                       usage
-                       ;;
-       esac
-done
-
-DATA_DIR=$DATA_DIR/data
-
-# If we're on an Easy Install system, use our own db_ tools.
-#
-if [ -x /usr/local/ctdlsupport/bin/db_dump ] ; then
-       export PATH=/usr/local/ctdlsupport/bin:$PATH
-       RECOVER=/usr/local/ctdlsupport/bin/db_recover
-       DUMP=/usr/local/ctdlsupport/bin/db_dump
-       LOAD=/usr/local/ctdlsupport/bin/db_load
-
-else
-       # ok usual install?
-       if test -f /usr/bin/db_dump; then 
-               RECOVER=/usr/bin/db_recover
-               DUMP=/usr/bin/db_dump
-               LOAD=/usr/bin/db_load
-       else
-               if test -n "`ls /usr/bin/db?*recover`"; then
-                       # seems we have something debian alike thats adding version in the filename
-                       if test "`ls /usr/bin/db*recover |wc -l`" -gt "1"; then 
-                               echo "Warning: you have more than one version of the Berkeley DB utilities installed." 1>&2
-                               echo "Using the latest one." 1>&2
-                               RECOVER=`ls /usr/bin/db*recover |sort |tail -n 1`
-                               DUMP=`ls /usr/bin/db*dump |sort |tail -n 1`
-                               LOAD=`ls /usr/bin/db*load |sort |tail -n 1`
-                       else
-                               RECOVER=`ls /usr/bin/db*recover`
-                               DUMP=`ls /usr/bin/db*dump`
-                               LOAD=`ls /usr/bin/db*load`
-                       fi
-               else
-                       echo "database_cleanup.sh cannot find the Berkeley DB utilities.  Exiting." 1>&2
-                       die
-               fi
-
-       fi
-fi
-
-# Ok, let's begin.
-#
-
-clear
-cat <<!
-
-Citadel Database Cleanup
----------------------------
-
-This script exports, deletes, and re-imports your database.  If you have
-any data corruption issues, this program may be able to clean them up for you.
-Please note that this program does a Berkeley DB dump/load, not a Citadel
-export.  The export files are not generated by the Citadel export module.
-
-WARNING #1:
-  MAKE A BACKUP OF YOUR DATA BEFORE ATTEMPTING THIS.  There is no guarantee
-  that this will work (in case of disk full, power failure, program crash)!
-
-WARNING #2:
-  citserver must NOT be running while you do this.
-
-WARNING #3:
-  Please try "cd $DATA_DIR; $RECOVER -c" first. Run citserver afterwards to 
-  revalidate whether its fixed or not, No news might be good news. Use this
-  tool only if that one fails to fix your problem.
-
-WARNING #4:
-  You must have an amount of free space on your disk that is at least twice
-  the size of your database, see the following output:
-  (for substantially better performance you should specify a location that is 
-   on another disk than $DATA_DIR)
-
-`df -h`
-
-you will need `du -sh $DATA_DIR|sed "s;/.*;;"` of free space.
-
-!
-
-echo We will attempt to look for a Citadel database in $DATA_DIR
-echo -n "Do you want to continue? "
-
-read yesno
-case "$yesno" in
-       "y" | "Y" | "yes" | "YES" | "Yes" )
-               echo 
-               echo DO NOT INTERRUPT THIS PROCESS.
-               echo
-       ;;
-       * )
-               exit
-esac
-
-for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
-do
-       filename=cdb.$x
-       echo Dumping $filename
-       $DUMP -h $DATA_DIR $filename >/tmp/CitaDump.$x || {
-               echo error $?
-               die
-       }
-       rm -f $DATA_DIR/$filename
-done
-
-echo Removing old databases
-rm -f ./data/*
-
-for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d
-do
-       filename=cdb.$x
-       echo Loading $filename
-       $LOAD -h $DATA_DIR $filename </tmp/CitaDump.$x && {
-               rm -f /tmp/CitaDump.$x
-       }
-done
-
-echo 
-echo Dump/load operation complete.  Start your Citadel server now.
-echo