diff --git a/actions/owncloud-setup b/actions/owncloud-setup index 83962f4ce..228931189 100755 --- a/actions/owncloud-setup +++ b/actions/owncloud-setup @@ -1,4 +1,6 @@ #!/bin/sh +# See also +# http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_automation.html if [ -e /etc/apache2/conf-enabled/owncloud.conf ] ; then owncloud_enable=true @@ -39,10 +41,59 @@ done if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then if $owncloud_enable ; then - DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -y owncloud 2>&1 | logger -t owncloud-setup - a2enconf owncloud 2>&1 | logger -t owncloud-setup + # Select postgresql as the backend database for OwnCloud, and + # make sure its php support is enabled when owncloud is + # installed. + DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends \ + install -y postgresql php5-pgsql 2>&1 | logger -t owncloud-setup + DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends \ + install -y owncloud 2>&1 | logger -t owncloud-setup + + # Keep existing configuration if it exist + if [ ! -e /etc/owncloud/config.php ] ; 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'\"" \ + 2>&1 | logger -t owncloud-setup + su - postgres -c "createdb --owner owncloud owncloud" \ + 2>&1 | logger -t owncloud-setup + + cat > /etc/owncloud/autoconfig.php < '/usr/share/owncloud/data', + 'dbtype' => 'pgsql', + 'dbname' => 'owncloud', + 'dbuser' => 'owncloud', + 'dbpass' => '$dbpwd', + 'dbhost' => 'localhost', + 'dbtableprefix' => 'oc_', + + 'installed' => false, +); +EOF +# The default admin user and password set up in owncloud +# FIXME figure out how to pick username and password, perhaps from the +# plinth user database? +#adminuser=admin +#adminpwd=secret +# Use these in autoconfig.php to set admin username and password: +# 'adminlogin' => '$adminuser', +# 'adminpass' => '$adminpwd', + + a2enconf owncloud 2>&1 | logger -t owncloud-setup + service apache2 restart 2>&1 | logger -t owncloud-setup + + # Initialize application and database tables by visiting + # the front page. This only work if admin user and + # password was set above. + #wget --quiet http://$(uname -n)/owncloud/index.php + else + a2enconf owncloud 2>&1 | logger -t owncloud-setup + service apache2 restart 2>&1 | logger -t owncloud-setup + fi else a2disconf owncloud 2>&1 | logger -t owncloud-setup + service apache2 restart 2>&1 | logger -t owncloud-setup fi - service apache2 restart 2>&1 | logger -t owncloud-setup fi diff --git a/modules/installed/apps/owncloud.py b/modules/installed/apps/owncloud.py index fff75bc8c..26da6ac1b 100644 --- a/modules/installed/apps/owncloud.py +++ b/modules/installed/apps/owncloud.py @@ -42,7 +42,8 @@ class Owncloud(PagePlugin, FormPlugin): form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=owncloud_enable) # hidden field is needed because checkbox doesn't post if not checked form.hidden(name="submitted", value="True") - form.html(_("""

When enabled, the owncloud installation will be available from owncloud on the web server.

""")) + form.html(_("""

When enabled, the owncloud installation will be available from owncloud on the web server. Visit this URL to set up the initial administration account for owncloud.

""")) + form.html(_("""

Note: Setting up owncloud for the first time might take 5 minutes or more, depending on download bandwidth from the Debian APT sources.

""")) form.submit(_("Update setup")) return form.render()