From 57094d98203c4aaa6f04503da10412a0b2570643 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 15 Feb 2015 16:38:52 +0530 Subject: [PATCH] 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. --- actions/owncloud-setup | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/actions/owncloud-setup b/actions/owncloud-setup index bfe9cf14c..7dcebb578 100755 --- a/actions/owncloud-setup +++ b/actions/owncloud-setup @@ -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'\"" \