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

sudo verses su in delete-company-database.sh



Me personally I cannot use the delete-company-database.sh as supplied because my postgres user account is set up as not able to login.

What I have to do is use sudo prefixed in each of the four places su is used (see attached svn diff), since I have sudo su privileges configured for my personal, non-root user account.

Would this be considered an advisable approach more generally enough to warrant applying that patch to trunk?

Index: tools/delete-company-database.sh
===================================================================
--- tools/delete-company-database.sh	(revision 5130)
+++ tools/delete-company-database.sh	(working copy)
@@ -11,16 +11,16 @@
 fi
 
 cmd="select rolname FROM pg_roles WHERE rolname LIKE 'lsmb_${1}__%';"
-company_roles=`su -c "psql -U postgres -t -c \"$cmd\"" postgres`
+company_roles=`sudo su -c "psql -U postgres -t -c \"$cmd\"" postgres`
 
-su -c "dropdb -U postgres $1" postgres
+sudo su -c "dropdb -U postgres $1" postgres
 
 for role in $company_roles
 do
-  su -c "dropuser -U postgres \"$role\"" postgres
+  sudo su -c "dropuser -U postgres \"$role\"" postgres
 done
 
 if test -n "$2"
 then
-  su -c "dropuser -U postgres \"$2\"" postgres
+  sudo su -c "dropuser -U postgres \"$2\"" postgres
 fi