mirror of
https://github.com/YunoHost-Apps/nextcloud_ynh.git
synced 2024-09-03 19:55:57 +02:00
[enh] Ask to create local mount to user home folder at install
This commit is contained in:
parent
6d32b70388
commit
44d2b9ffe1
3 changed files with 40 additions and 20 deletions
|
@ -51,6 +51,15 @@
|
||||||
"fr": "Choisissez l'administrateur d'Owncloud (doit être un utilisateur YunoHost déjà existant)"
|
"fr": "Choisissez l'administrateur d'Owncloud (doit être un utilisateur YunoHost déjà existant)"
|
||||||
},
|
},
|
||||||
"example": "homer"
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
domain=$1
|
domain=$1
|
||||||
path=${2%/}
|
path=${2%/}
|
||||||
admin=$3
|
admin=$3
|
||||||
|
user_home=$4
|
||||||
|
|
||||||
# Load common variables
|
# Load common variables
|
||||||
. ./_common.sh
|
. ./_common.sh
|
||||||
|
@ -44,7 +45,6 @@ ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
|
||||||
|
|
||||||
# Generate random password
|
# Generate random password
|
||||||
dbpass=$(ynh_string_random)
|
dbpass=$(ynh_string_random)
|
||||||
ynh_app_setting_set $app mysqlpwd $dbpass
|
|
||||||
|
|
||||||
# Initialize database
|
# Initialize database
|
||||||
ynh_mysql_create_db $dbname $dbuser $dbpass
|
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
|
sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json
|
||||||
sudo cp ../conf/config.json "$oc_conf"
|
sudo cp ../conf/config.json "$oc_conf"
|
||||||
|
|
||||||
# Copy configuration for external storage plugin
|
|
||||||
sudo cp ../conf/mount.json "$DATADIR"
|
|
||||||
|
|
||||||
# Copy and set nginx configuration
|
# Copy and set nginx configuration
|
||||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
|
sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
|
||||||
|
@ -116,10 +113,12 @@ sudo rm -f "$oc_conf"
|
||||||
_exec_occ ldap:test-config \'\' \
|
_exec_occ ldap:test-config \'\' \
|
||||||
|| ynh_die "An error occured during LDAP configuration"
|
|| ynh_die "An error occured during LDAP configuration"
|
||||||
|
|
||||||
# Enable External Storage and create local mount
|
# Enable External Storage and create local mount to home folder
|
||||||
_exec_occ app:enable files_external
|
if [[ $user_home -eq 1 ]]; then
|
||||||
_exec_occ files_external:create \
|
_exec_occ app:enable files_external
|
||||||
'Home' 'local' 'null::null' -c 'datadir=/home/$user'
|
_exec_occ files_external:create \
|
||||||
|
'Home' 'local' 'null::null' -c 'datadir=/home/$user'
|
||||||
|
fi
|
||||||
|
|
||||||
# Add dynamic logout URL to the config
|
# Add dynamic logout URL to the config
|
||||||
_exec_occ config:system:get logout_url >/dev/null 2>&1 \
|
_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 640 "${DESTDIR}/config/config.php"
|
||||||
sudo chmod 755 /home/yunohost.app
|
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
|
# Set SSOwat rules
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/remote.php"
|
ynh_app_setting_set "$app" unprotected_uris "/remote.php"
|
||||||
ynh_app_setting_set "$app" skipped_uris "/.well-known"
|
ynh_app_setting_set "$app" skipped_uris "/.well-known"
|
||||||
|
|
|
@ -16,10 +16,11 @@ dbuser=$app
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get $app path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
path=${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
|
# Check destination directory
|
||||||
DESTDIR="/var/www/$app"
|
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
|
sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json
|
||||||
sudo cp ../conf/config.json "${TMPDIR}/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
|
# Enable maintenance mode
|
||||||
_exec_occ maintenance:mode --on
|
_exec_occ maintenance:mode --on
|
||||||
|
|
||||||
|
@ -104,12 +102,22 @@ _exec_occ app:enable user_ldap
|
||||||
_exec_occ config:import "$oc_conf"
|
_exec_occ config:import "$oc_conf"
|
||||||
sudo rm -f "$oc_conf"
|
sudo rm -f "$oc_conf"
|
||||||
|
|
||||||
# Enable External Storage and create local mount as needed
|
# Guess user_home value if empty
|
||||||
_exec_occ app:enable files_external
|
if [[ -z "${user_home:-}" ]]; then
|
||||||
_exec_occ files_external:list --output=json \
|
sudo cat "${DATADIR}/mount.json" >/dev/null 2>&1 \
|
||||||
| grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
|
&& user_home=1 \
|
||||||
|| _exec_occ files_external:create \
|
|| user_home=0
|
||||||
'Home' 'local' 'null::null' -c 'datadir=/home/$user'
|
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
|
# Add dynamic logout URL to the config
|
||||||
# TODO: if changes are made to this section, replace it with new one.
|
# TODO: if changes are made to this section, replace it with new one.
|
||||||
|
|
Loading…
Add table
Reference in a new issue