mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
Merge pull request #72 from petterreinholdtsen/owncloud-autoconfig
Merged: Pere's add code to enable owncloud by default using PostgreSQL.
This commit is contained in:
commit
66d0114d8f
@ -1,4 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/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
|
if [ -e /etc/apache2/conf-enabled/owncloud.conf ] ; then
|
||||||
owncloud_enable=true
|
owncloud_enable=true
|
||||||
@ -39,10 +41,59 @@ done
|
|||||||
|
|
||||||
if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then
|
if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then
|
||||||
if $owncloud_enable ; then
|
if $owncloud_enable ; then
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -y owncloud 2>&1 | logger -t owncloud-setup
|
# Select postgresql as the backend database for OwnCloud, and
|
||||||
a2enconf owncloud 2>&1 | logger -t owncloud-setup
|
# 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
|
else
|
||||||
a2disconf owncloud 2>&1 | logger -t owncloud-setup
|
a2disconf owncloud 2>&1 | logger -t owncloud-setup
|
||||||
|
service apache2 restart 2>&1 | logger -t owncloud-setup
|
||||||
fi
|
fi
|
||||||
service apache2 restart 2>&1 | logger -t owncloud-setup
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -42,7 +42,8 @@ class Owncloud(PagePlugin, FormPlugin):
|
|||||||
form.checkbox(_("Enable Owncloud"), name="owncloud_enable", id="owncloud_enable", checked=owncloud_enable)
|
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
|
# hidden field is needed because checkbox doesn't post if not checked
|
||||||
form.hidden(name="submitted", value="True")
|
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"))
|
form.submit(_("Update setup"))
|
||||||
return form.render()
|
return form.render()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user