summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-11-22 11:10:10 -0800
committerBrion Vibber <brion@pobox.com>2010-11-22 11:10:10 -0800
commit9c6e63b0bcccadddfa67c89fe86c56df73af3e33 (patch)
treef6af24a96ee129ece82ec0fb5c6242f88d3f9eaf /scripts
parentb6159983099e40444ef552b78870e13f60f33545 (diff)
Fixes for delete_status_network.sh:
* add some sanity checking: abort on failures instead of plodding through * add some progress / error output * fetch the target database server name from the status_network entry and use that to target the DROP DATABASE Note that database names and other overrides in status_network entry may still not be seen.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/delete_status_network.sh39
1 files changed, 31 insertions, 8 deletions
diff --git a/scripts/delete_status_network.sh b/scripts/delete_status_network.sh
index 3a8ebdcfd..4e91cd639 100755
--- a/scripts/delete_status_network.sh
+++ b/scripts/delete_status_network.sh
@@ -4,22 +4,45 @@
set -e
-source /etc/statusnet/setup.cfg
+source /etc/statusnet/setup.cfg || (echo "Failed to read /etc/statusnet/setup.cfg"; exit -1)
export nickname=$1
+if [ "x" == "x$nickname" ]
+then
+ echo "Usage: delete_status_network.sh <site-nickname>"
+ exit 1
+fi
export database=$nickname$DBBASE
-# Create the db
+# Pull the status_network record so we know which DB server to drop from...
+TARGET_DBHOST=`mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB --batch --skip-column-names -e \
+ "select dbhost from status_network where nickname='$nickname'"`
-mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS -f drop $database
+if [ "x" == "x$TARGET_DBHOST" ]
+then
+ echo "Aborting: Could not find status_network record for site $nickname"
+ exit 1
+fi
-mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
+# Drop the database
+echo "Dropping $database from $TARGET_DBHOST..."
+mysqladmin -h $TARGET_DBHOST -u $ADMIN --password=$ADMINPASS -f drop $database || exit 1
-delete from status_network where nickname = '$nickname';
-
-ENDOFCOMMANDS
+# Remove the status_network entry
+echo "Removing status_network entry for $nickname..."
+mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB -e \
+ "delete from status_network where nickname = '$nickname'" || exit 1
+# Remove uploaded file areas
for top in $AVATARBASE $FILEBASE $BACKGROUNDBASE; do
- rm -Rf $top/$nickname
+ if [ "x" == "x$top" ]
+ then
+ echo "Skipping deletion due to broken config"
+ else
+ echo "Deleting $top/$nickname"
+ rm -Rf "$top/$nickname"
+ fi
done
+
+echo "Done."