From d8cc97fe74076ad6b95a47308eb16441940e279b Mon Sep 17 00:00:00 2001 From: Liz Rea Date: Tue, 3 Nov 2015 16:17:01 +1300 Subject: [PATCH] [SIGNED-OFF] Bug 15088 - notice when koha has been installed with --request-db instead of --create-db Patch does 2 major things - * creates an options file during koha-create that lets us know what database option was used when the instance was created /etc/koha/sites/$name/createoptions * when an instance is removed, we assume we can do things to the database, per usual. If we have a createoptions, we'll read it and find out if our instance was created with create-db or request-db. If it was requested, we don't do anything with the database because we assume we don't have rights to, and print a message. If it was created, we do the same thing we've always done - remove the database and users (unless we've specified --keep-mysql) To test: create a throwaway instance with --create-db remove that instance, all should happen as normal. your instance should have an /etc/koha/sites/$name/createoptions file with REQUEST_DB=0 in it. create another throwaway instance with --request-db remove that instance, you should see a message alerting you to the fact that you may still have database work to do after Koha is removed. your instance should have an /etc/koha/sites/$name/createoptions file with REQUEST_DB=1 in it. Signed-off-by: Mark Tompsett --- debian/scripts/koha-create | 15 +++++++++++++++ debian/scripts/koha-remove | 37 ++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index a36f7e3..ef6891f 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -575,6 +575,9 @@ then zebrapwd="$(pwgen -s 16 1)" # Future enhancement: make this configurable for when your db is on # another server. + touch "/etc/koha/sites/$name/createoptions" + chown "$username:$username" "/etc/koha/sites/$name/createoptions" + mysql_hostname="localhost" # Set up MySQL database for this instance. if [ "$op" = create ] @@ -641,6 +644,11 @@ database user: $mysqluser Thank you. eof + cat > "/etc/koha/sites/$name/createoptions" << eof +# do not edit this file, it is for record keeping purposes only +REQUEST_DB=1 +eof + echo "See $name-db-request.txt for database creation request." echo "Please forward it to the right person, and then run" echo "$0 --populate-db $name" @@ -678,6 +686,13 @@ UPDATE borrowers SET password = '$staffdigest' WHERE borrowernumber = $ADMINUSER; eof + + cat > "/etc/koha/sites/$name/createoptions" << eof +# do not edit this file, it is for record keeping purposes only +REQUEST_DB=0 +eof + + #` echo "staff user password is '$staffpass' but keep that secret" diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove index 88392ba..646499e 100755 --- a/debian/scripts/koha-remove +++ b/debian/scripts/koha-remove @@ -62,20 +62,31 @@ do fi echo "Removing Koha instance $name" - mysql_hostname="localhost" - if [ "$keepmysql" != "1" ] - then - # The grant creates the user in case it isn't, we don't want our loop to fail if it has already being deleted. - mysql --defaults-extra-file=/etc/mysql/koha-common.cnf <