owncloud: Check for database configuration to treat as enabled

- Newer version of owncloud package enable the Apache2 owncloud configuration
  by default.  This happens eventhough database configuraiton is not available.
  Plinth only checks for Apache2 owncloud configuration as enabled to determine
  if owncloud is enabled and hence falsely shows the owncloud is enabled.

- Newer version of owncloud also create a /etc/owncloud/config.php with simple
  instance identifier set.  So merely checking if the files exists is not of
  much use.

- This patch checks if the dbtype variable is configured in config.php or
  autoconfig.php along with Apache2 owncloud configuration to determine if
  owncloud is enabled.

- The same logic is used to determine if autoconfig.php must be generated.
This commit is contained in:
Sunil Mohan Adapa 2015-02-15 16:38:52 +05:30
parent 855755263d
commit 57094d9820

View File

@ -19,13 +19,18 @@
# 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
grep -q "^\s*['\"]dbtype['\"]" /etc/owncloud/config.php 2> /dev/null
db_in_config=$(( ! $? ))
grep -q "^\s*['\"]dbtype['\"]" /etc/owncloud/autoconfig.php 2> /dev/null
db_in_autoconfig=$(( ! $? ))
if [ -e /etc/apache2/conf-enabled/owncloud.conf ] && \
[ $db_in_config -ne 0 -o $db_in_autoconfig -ne 0 ] ; then
owncloud_enable_cur=true
else
owncloud_enable=false
owncloud_enable_cur=false
fi
owncloud_enable_cur=$owncloud_enable
export owncloud_enable
while [ "$1" ] ; do
@ -59,7 +64,7 @@ done
if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then
if $owncloud_enable ; then
# Keep existing configuration if it exist
if [ ! -e /etc/owncloud/config.php ] ; 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'\"" \