From 2dd303e9acf7cbd36e37e39e4ba3687134a8d153 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 15 Feb 2015 16:52:09 +0530 Subject: [PATCH] owncloud: Make setup more robust to repeatition Create postgresql user and set password in two steps instead of one. This ensures that if a user already exists for some reason (setup already run), then re-running will simply set a new password and generates a new configuration. Otherwise, the user creation setup having failed because of existing user will also fail to set new password and the generated configuration is not usable. --- actions/owncloud-setup | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actions/owncloud-setup b/actions/owncloud-setup index 1f7d3a58a..dc3401834 100755 --- a/actions/owncloud-setup +++ b/actions/owncloud-setup @@ -66,7 +66,9 @@ if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then if [ $db_in_config -eq 0 -a $db_in_autoconfig -eq 0 ] ; then # Set up postgresql database and user dbpwd=$(pwgen -1 30) - su - postgres -c "psql -c \"CREATE USER owncloud WITH NOCREATEDB NOCREATEUSER ENCRYPTED PASSWORD '$dbpwd'\"" \ + su - postgres -c "psql -c \"CREATE USER owncloud WITH NOCREATEDB NOCREATEUSER\"" \ + 2>&1 | logger -t owncloud-setup + su - postgres -c "psql -c \"ALTER USER owncloud ENCRYPTED PASSWORD '$dbpwd'\"" \ 2>&1 | logger -t owncloud-setup su - postgres -c "createdb --owner owncloud owncloud" \ 2>&1 | logger -t owncloud-setup