Add code to enable owncloud by default using PostgreSQL. Only need to specify the admin username and password to get going.

This commit is contained in:
Petter Reinholdtsen 2014-04-05 21:39:05 +02:00
parent 890bc7ea99
commit d71d94f2d7
2 changed files with 56 additions and 4 deletions

View File

@ -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 <<EOF
<?php
\$AUTOCONFIG = array(
'directory' => '/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

View File

@ -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(_("""<p>When enabled, the owncloud installation will be available from <a href="/owncloud">owncloud</a> on the web server.</p>"""))
form.html(_("""<p>When enabled, the owncloud installation will be available from <a href="/owncloud">owncloud</a> on the web server. Visit this URL to set up the initial administration account for owncloud.</p>"""))
form.html(_("""<p><strong>Note: Setting up owncloud for the first time might take 5 minutes or more, depending on download bandwidth from the Debian APT sources.</p>"""))
form.submit(_("Update setup"))
return form.render()