From 9e86c67534a24c491b79ad4603ce8cf4a0849ea8 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 16 Aug 2014 12:38:03 +0000 Subject: [PATCH] make setup/owncloud.sh idempotent: don't wreck user data on second run --- setup/owncloud.sh | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index a1e8b3a..4f01141 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -22,10 +22,13 @@ if [ ! -d /usr/local/lib/owncloud ]; then rm -f /tmp/owncloud.zip fi -# Create a configuration file. -TIMEZONE=`cat /etc/timezone` -instanceid=oc$(echo $PRIMARY_HOSTNAME | sha1sum | fold -w 10 | head -n 1) -cat - > /usr/local/lib/owncloud/config/config.php < /usr/local/lib/owncloud/config/config.php < '$STORAGE_ROOT/owncloud', @@ -63,9 +66,11 @@ cat - > /usr/local/lib/owncloud/config/config.php < EOF -# Create an auto-configuration file to fill in database settings. -adminpassword=$(dd if=/dev/random bs=40 count=1 2>/dev/null | sha1sum | fold -w 30 | head -n 1) -cat - > /usr/local/lib/owncloud/config/autoconfig.php </dev/null | sha1sum | fold -w 30 | head -n 1) + cat - > /usr/local/lib/owncloud/config/autoconfig.php < /usr/local/lib/owncloud/config/autoconfig.php < EOF -# Set permissions -mkdir -p $STORAGE_ROOT/owncloud -chown -R www-data.www-data $STORAGE_ROOT/owncloud /usr/local/lib/owncloud + # Create user data directory and set permissions + mkdir -p $STORAGE_ROOT/owncloud + chown -R www-data.www-data $STORAGE_ROOT/owncloud /usr/local/lib/owncloud -# Execute ownCloud's setup step, which creates the ownCloud sqlite database. -# It also wipes it if it exists. And it deletes the autoconfig.php file. -(cd /usr/local/lib/owncloud; sudo -u www-data php /usr/local/lib/owncloud/index.php;) + # Execute ownCloud's setup step, which creates the ownCloud sqlite database. + # It also wipes it if it exists. And it deletes the autoconfig.php file. + (cd /usr/local/lib/owncloud; sudo -u www-data php /usr/local/lib/owncloud/index.php;) +fi # Enable/disable apps. Note that this must be done after the ownCloud setup. # The firstrunwizard gave Josh all sorts of problems, so disabling that.