2009-06-23 19:40:23 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-01-29 20:33:35 +00:00
|
|
|
# live fast! die young!
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
source /etc/statusnet/setup.cfg || (echo "Failed to read /etc/statusnet/setup.cfg"; exit -1)
|
2009-06-23 19:40:23 +01:00
|
|
|
|
|
|
|
export nickname=$1
|
2010-11-22 19:10:10 +00:00
|
|
|
if [ "x" == "x$nickname" ]
|
|
|
|
then
|
|
|
|
echo "Usage: delete_status_network.sh <site-nickname>"
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-06-23 19:40:23 +01:00
|
|
|
|
|
|
|
export database=$nickname$DBBASE
|
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
# 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'"`
|
2009-06-23 19:40:23 +01:00
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
if [ "x" == "x$TARGET_DBHOST" ]
|
|
|
|
then
|
|
|
|
echo "Aborting: Could not find status_network record for site $nickname"
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-06-23 19:40:23 +01:00
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
# Drop the database
|
|
|
|
echo "Dropping $database from $TARGET_DBHOST..."
|
|
|
|
mysqladmin -h $TARGET_DBHOST -u $ADMIN --password=$ADMINPASS -f drop $database || exit 1
|
2009-06-23 19:40:23 +01:00
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
# 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
|
2009-06-23 19:40:23 +01:00
|
|
|
|
2010-11-22 19:10:10 +00:00
|
|
|
# Remove uploaded file areas
|
2009-06-23 19:40:23 +01:00
|
|
|
for top in $AVATARBASE $FILEBASE $BACKGROUNDBASE; do
|
2010-11-22 19:10:10 +00:00
|
|
|
if [ "x" == "x$top" ]
|
|
|
|
then
|
|
|
|
echo "Skipping deletion due to broken config"
|
|
|
|
else
|
|
|
|
echo "Deleting $top/$nickname"
|
|
|
|
rm -Rf "$top/$nickname"
|
|
|
|
fi
|
2009-06-23 19:40:23 +01:00
|
|
|
done
|
2010-11-22 19:10:10 +00:00
|
|
|
|
|
|
|
echo "Done."
|