From d5b663c417bc29e9f13045f1eaf7d844550d6873 Mon Sep 17 00:00:00 2001 From: Paul Bredenberg Date: Sat, 9 Apr 2016 23:39:16 -0400 Subject: [PATCH] completed database and user removal tools --- install | 7 +++---- lempdash | 2 +- tasks/mysql/removedb | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/install b/install index d413c81..e74bd3f 100755 --- a/install +++ b/install @@ -7,13 +7,12 @@ # Check dependencies for mission critical stuff type zip >/dev/null 2>&1 || echo "The package 'zip' is not installed on your system, so installing..." && apt-get install zip -# Make task scripts executlable -chmod +x lempdash -find ./tasks/ -type f -exec /bin/sh -c "file {} | grep -q executable && chmod +x {}" \; - # Copy all the things into bin mkdir -p /opt/lempdash/tasks cp -R tasks /opt/lempdash cp lempdash /bin/ldash +# Make task scripts executlable +chmod +x /bin/ldash +find /opt/lempdash/tasks/ -type f -exec /bin/sh -c "file {} | grep -q executable && chmod +x {}" \; \ No newline at end of file diff --git a/lempdash b/lempdash index b45c7f3..1f9fc81 100755 --- a/lempdash +++ b/lempdash @@ -50,7 +50,7 @@ elif [ $1 = "rm" ]; then # REMOVE DATABASE USER elif [ $2 = "dbuser" ]; then if [ $# = 3 ]; then - echo "Dropping user: $3" "$3" + echo "Dropping user: " $3 /opt/lempdash/tasks/mysql/removeuser "$3" else echo $ADDRESSEE$DONTF"specify a user name: ldash rm dbuser USERNAME" diff --git a/tasks/mysql/removedb b/tasks/mysql/removedb index 463c6c3..d2d5489 100755 --- a/tasks/mysql/removedb +++ b/tasks/mysql/removedb @@ -3,15 +3,15 @@ MYSQL=`which mysql` CURRENT_TIME=$(date "+%Y%m%d-%H%M%S") -FILE_NAME=$CURRENT_TIME'.sql' +FILE_NAME=$1$CURRENT_TIME'.sql' Q1="DROP DATABASE IF EXISTS $1;" -SQL="${Q1}" +SQL="$Q1" echo "First I'll need your MySQL root user password to backup your database." read -sp 'Password: ' PASSVAR mkdir -p /var/www/archive -mysqldump -uroot -p$PASSVAR $Q1 > /var/www/archive/$Q1$CURRENT_TIME'.sql' +mysqldump -uroot -p$PASSVAR $1 > /var/www/archive/$FILE_NAME $MYSQL -uroot -p$PASSVAR -e "$SQL" \ No newline at end of file