X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fdatabase_cleanup.sh.in;h=e2815497d6f8e19296f616923bb2ed965bf43d49;hb=3334c6073b74551d18176701092179deb5b9ef06;hp=6b786300696087729d267ef42952ee4829efbda1;hpb=aa5c9fe88e18df48c2121ac16d32b4f1d1d1dbc3;p=citadel.git diff --git a/citadel/database_cleanup.sh.in b/citadel/database_cleanup.sh.in index 6b7863006..e2815497d 100755 --- a/citadel/database_cleanup.sh.in +++ b/citadel/database_cleanup.sh.in @@ -5,11 +5,39 @@ die () { exit 1 } -# data dir from autoconf? -DATA_DIR="@MAKE_DATA_DIR@" -if test -z "$DATA_DIR" ; then - DATA_DIR="/usr/local/citadel" +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. @@ -35,6 +63,10 @@ else 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 @@ -67,8 +99,9 @@ WARNING #2: citserver must NOT be running while you do this. WARNING #3: - Please try "cd $DATA_DIR; $RECOVER -c" first. Use this tool - only if that one fails to fix your problem. + 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 @@ -82,6 +115,7 @@ 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 @@ -95,18 +129,21 @@ case "$yesno" in exit esac -for x in 00 01 02 03 04 05 06 07 08 09 0a +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 || die + $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 +for x in 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d do filename=cdb.$x echo Loading $filename