diff --git a/manifest.json b/manifest.json index 6d6875f..ce15497 100644 --- a/manifest.json +++ b/manifest.json @@ -51,6 +51,15 @@ "fr": "Choisissez l'administrateur d'Owncloud (doit être un utilisateur YunoHost déjà existant)" }, "example": "homer" + }, + { + "name": "user_home", + "type": "boolean", + "ask": { + "en": "Access the users home folder from ownCloud?", + "fr": "Accéder au dossier personnel des utilisateurs depuis ownCloud ?" + }, + "default": false } ] } diff --git a/scripts/install b/scripts/install index 8bc885e..1fa8359 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$1 path=${2%/} admin=$3 +user_home=$4 # Load common variables . ./_common.sh @@ -44,7 +45,6 @@ ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \ # Generate random password dbpass=$(ynh_string_random) -ynh_app_setting_set $app mysqlpwd $dbpass # Initialize database ynh_mysql_create_db $dbname $dbuser $dbpass @@ -66,9 +66,6 @@ sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json sudo cp ../conf/config.json "$oc_conf" -# Copy configuration for external storage plugin -sudo cp ../conf/mount.json "$DATADIR" - # Copy and set nginx configuration nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" sed -i "s@#APP#@${app}@g" ../conf/nginx.conf @@ -116,10 +113,12 @@ sudo rm -f "$oc_conf" _exec_occ ldap:test-config \'\' \ || ynh_die "An error occured during LDAP configuration" -# Enable External Storage and create local mount -_exec_occ app:enable files_external -_exec_occ files_external:create \ - 'Home' 'local' 'null::null' -c 'datadir=/home/$user' +# Enable External Storage and create local mount to home folder +if [[ $user_home -eq 1 ]]; then + _exec_occ app:enable files_external + _exec_occ files_external:create \ + 'Home' 'local' 'null::null' -c 'datadir=/home/$user' +fi # Add dynamic logout URL to the config _exec_occ config:system:get logout_url >/dev/null 2>&1 \ @@ -152,6 +151,10 @@ sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750 sudo chmod 640 "${DESTDIR}/config/config.php" sudo chmod 755 /home/yunohost.app +# Store app settings +ynh_app_setting_set "$app" user_home "$user_home" +ynh_app_setting_set "$app" mysqlpwd "$dbpass" + # Set SSOwat rules ynh_app_setting_set "$app" unprotected_uris "/remote.php" ynh_app_setting_set "$app" skipped_uris "/.well-known" diff --git a/scripts/upgrade b/scripts/upgrade index 126a336..370654b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,10 +16,11 @@ dbuser=$app . /usr/share/yunohost/helpers # Retrieve app settings -domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) path=${path%/} -dbpass=$(ynh_app_setting_get $app mysqlpwd) +dbpass=$(ynh_app_setting_get "$app" mysqlpwd) +user_home=$(ynh_app_setting_get "$app" user_home) # Check destination directory DESTDIR="/var/www/$app" @@ -73,9 +74,6 @@ sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json sudo cp ../conf/config.json "${TMPDIR}/config.json" -# Copy configuration for external storage plugin -sudo cp ../conf/mount.json "$DATADIR" - # Enable maintenance mode _exec_occ maintenance:mode --on @@ -104,12 +102,22 @@ _exec_occ app:enable user_ldap _exec_occ config:import "$oc_conf" sudo rm -f "$oc_conf" -# Enable External Storage and create local mount as needed -_exec_occ app:enable files_external -_exec_occ files_external:list --output=json \ - | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ - || _exec_occ files_external:create \ - 'Home' 'local' 'null::null' -c 'datadir=/home/$user' +# Guess user_home value if empty +if [[ -z "${user_home:-}" ]]; then + sudo cat "${DATADIR}/mount.json" >/dev/null 2>&1 \ + && user_home=1 \ + || user_home=0 + ynh_app_setting_set "$app" user_home "$user_home" +fi + +# Enable External Storage and create local mount to home folder as needed +if [[ ${user_home} -eq 1 ]]; then + _exec_occ app:enable files_external + _exec_occ files_external:list --output=json \ + | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \ + || _exec_occ files_external:create \ + 'Home' 'local' 'null::null' -c 'datadir=/home/$user' +fi # Add dynamic logout URL to the config # TODO: if changes are made to this section, replace it with new one.