Tim Landscheidt has uploaded a new change for review. https://gerrit.wikimedia.org/r/122274
Change subject: WIP: Update rmtool ...................................................................... WIP: Update rmtool Change-Id: If40471197a8797386b89362016f5a3c6c0c86c48 --- M configure.ac M debian/changelog M misctools/rmtool 3 files changed, 50 insertions(+), 65 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/toollabs refs/changes/74/122274/1 diff --git a/configure.ac b/configure.ac index 92d1b80..d2b4f81 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([toollabs], [1.0.4dev], [mpellet...@wikimedia.org]) +AC_INIT([toollabs], [1.0.8dev], [mpellet...@wikimedia.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_TESTDIR([tests]) diff --git a/debian/changelog b/debian/changelog index a3b166b..b743b50 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +toollabs (1.0.8dev) unstable; urgency=low + + * Update rmtool + + -- Tim Landscheidt <t...@tim-landscheidt.de> Sun, 30 Mar 2014 20:06:52 +0000 + toollabs (1.0.7) unstable; urgency=low * Marc-André Pelletier: fixes for eqiad diff --git a/misctools/rmtool b/misctools/rmtool index 06a7696..2129d05 100755 --- a/misctools/rmtool +++ b/misctools/rmtool @@ -1,13 +1,18 @@ #!/bin/bash -if [ $UID -gt 0 ];then - echo "Error you must be root" - exit 2 +if [ $UID -gt 0 ]; then + echo "Error you must be root" + exit 2 fi -if [ $# -lt 1 ];then - echo "You need to provide a tool name" - exit 1 +if [ $# -lt 1 ]; then + echo "You need to provide a tool name" + exit 1 +fi + +if [ ! -d /data/project/.system/removed_tools ]; then + echo "There is no folder to store removed tools!" + exit 1 fi tool=$1 @@ -18,9 +23,9 @@ echo "There is $uc user accounts of name $dbuser in database" -if [ "$uc" -gt 0 ];then - echo "Removing db access of $tool" - echo "drop user $dbuser;" | mysql mysql +if [ "$uc" -gt 0 ]; then + echo "Removing db access of $tool" + echo "drop user $dbuser;" | mysql mysql fi # get the number of databases for this user @@ -28,64 +33,38 @@ echo "There is $db databases of name $tool in database" -if [ "$db" -gt 0 ];then - echo "Creating a backup of database $tool" - if [ -f "/data/project/$tool/database_backup.sql" ];then - echo "Error there is already a backup file" - exit 1 - fi - if [ ! -d "/data/project/$tool" ];then - echo "There is no folder to save backup of db to!" - exit 1 - fi - mysqldump "$dbuser" > "/data/project/$tool/database_backup.sql" - echo "Removing db access of $tool" - echo "drop database $dbuser;" | mysql mysql +if [ "$db" -gt 0 ]; then + echo "Creating a backup of database $tool" + if [ -f "/data/project/$tool/database_backup.sql" ]; then + echo "Error there is already a backup file" + exit 1 + fi + if [ ! -d "/data/project/$tool" ]; then + echo "There is no folder to save backup of db to!" + exit 1 + fi + mysqldump "$dbuser" > "/data/project/$tool/database_backup.sql" + echo "Removing db access of $tool" + echo "DROP DATABASE $dbuser;" | mysql mysql fi -if [ ! -d /data/project/removed_tools ];then - echo "There is no folder to store removed tools!" - exit 1 -fi - -if [ -d "/data/project/$tool" ];then - echo "Removing data folder for $tool" - if [ -d "/data/project/removed_tools/$tool" ];then - echo "Unable to remove the folder, there is already backup folder with this name" - exit 1 +if [ -d "/data/project/$tool" ]; then + echo "Removing data folder for $tool" + if [ -d "/data/project/.system/removed_tools/$tool" ]; then + echo "Unable to remove the folder, there is already backup folder with this name" + exit 1 + fi + mv -i "/data/project/$tool" "/data/project/.system/removed_tools/$tool/" + if [ -f "/data/project/.system/removed_tools/$tool.tar.gz" ]; then + echo "Unable to tarball the folder because there is another tarball with same name" + else + cd /data/project/.system/removed_tools + tar -zcvf "$tool.tar.gz" "$tool" + if [ -f "/data/project/.system/removed_tools/$tool.tar.gz" ]; then + echo Deleting project folder + rm -rf "/data/project/.system/removed_tools/$tool" fi - mv "/data/project/$tool" "/data/project/removed_tools/$tool/" - if [ -f "/data/project/removed_tools/$tool.tar.gz" ];then - echo "Unable to tarball the folder because there is another tarball with same name" - else - cd /data/project/removed_tools - tar -zcvf "$tool.tar.gz" "$tool" - if [ -f "/data/project/removed_tools/$tool.tar.gz" ];then - echo Deleting project folder - rm -rf "/data/project/removed_tools/$tool" - fi - fi + fi fi - -# get a number of records in /data/project/.system/webservers - -while [ -f /data/project/.system/webservers.lock ] -do - echo "There is a lockfile, sleeping for 10 seconds" - sleep 10 -done - -touch /data/project/.system/webservers.lock -wc=`cat /data/project/.system/webservers | grep -Ec "^$tool\s.*"` - -if [ "$wc" -gt 0 ];then - # create a backup file so that if stuff get fucked up we can recover it - cp /data/project/.system/webservers /tmp/webservers.backup.`date +%H:%M:%S` - echo "Removing webserver" - cat /data/project/.system/webservers | grep -vE "^$tool\s.*" > /tmp/webservers - mv /tmp/webservers /data/project/.system/webservers -fi - -rm /data/project/.system/webservers.lock echo "All data for $tool were cleaned" -- To view, visit https://gerrit.wikimedia.org/r/122274 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If40471197a8797386b89362016f5a3c6c0c86c48 Gerrit-PatchSet: 1 Gerrit-Project: labs/toollabs Gerrit-Branch: master Gerrit-Owner: Tim Landscheidt <t...@tim-landscheidt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits