[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

delete-company-database.sh concerns and patch



Hello Erik, Chris, and all

I assume the delete-company-database.sh script was written by Erik, to go with the prep script also in tools.

I ran into a situation, where running it with no parameters to see what would break, appeared to be deleting several companies or roles.

I have added the usage in the attached patch, both to show users what is expected, and to prevent it running with no defined company database.

However, particularly with regard to the second parameter, I'm not exactly sure what is intended. I have given it a generic description which may serve, but if someone with a greater understanding could have a look at my proposed usage, and the script itself, and confirm (or edit the patch to make it correct), it would be better.

Thanks

Luke
--- orig/tools/delete-company-database.sh	2011-06-14 22:03:22.000000000 +0000
+++ delete-company-database.sh	2011-06-16 20:16:20.000000000 +0000
@@ -1,5 +1,15 @@
 #!/bin/sh
 
+# Simple check to print usage, and prevent runaway deletion
+if test -z "$1"
+then
+  echo "Usage: $0 COMPANY [ USER ]"
+  echo "\"COMPANY\" is the name of the company database, such as the name given"
+  echo "to --company when using the prepare-company-database.sh script."
+  echo "\"USER\" is an optional PGSQL user to remove."
+  exit 1
+fi
+
 cmd="select rolname FROM pg_roles WHERE rolname LIKE 'lsmb_${1}__%';"
 company_roles=`su -c "psql -U postgres -t -c \"$cmd\"" postgres`