From f72137d3663d62b1e9a2f825c7a9c03ef96ffc22 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Wed, 16 Feb 2022 21:27:51 +0100 Subject: [PATCH] Fix linter warning : home folder --- scripts/backup | 2 +- scripts/install | 16 ++++++++-------- scripts/remove | 2 +- scripts/restore | 8 ++++---- scripts/upgrade | 21 ++++++++++++++------- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/scripts/backup b/scripts/backup index b9558d8..5b86015 100755 --- a/scripts/backup +++ b/scripts/backup @@ -76,7 +76,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/home/$app/" +ynh_backup --src_path="/home/yunohost.app/$app/" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index ecb56bf..c0bafb2 100755 --- a/scripts/install +++ b/scripts/install @@ -86,7 +86,7 @@ ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user #UMS require a home path for the user as config files are stored in there -ynh_system_user_create --username=$app --home_dir=/home/$app +ynh_system_user_create --username=$app --home_dir=/home/yunohost.app/$app #================================================= #SETTING MULTIMEDIA DIRECTORY @@ -141,13 +141,13 @@ ynh_add_systemd_config ynh_script_progression --message="Setting up configuration file.." --weight=5 #UMS read config file from .config/UMS folder -mkdir -p "/home/$app/.config/UMS" -ynh_add_config --template="UMS.conf.default" --destination="/home/$app/.config/UMS/UMS.conf" -ynh_add_config --template="WEB.conf.default" --destination="/home/$app/.config/UMS/WEB.conf" -ynh_add_config --template="VirtualFolders.conf.default" --destination="/home/$app/.config/UMS/VirtualFolders.conf" -chown -R $app:$app "/home/$app/.config" -chmod -R 700 "/home/$app/.config" -#chmod 600 "/home/$app/.config/UMS/*" +mkdir -p "/home/yunohost.app/$app/.config/UMS" +ynh_add_config --template="UMS.conf.default" --destination="/home/yunohost.app/$app/.config/UMS/UMS.conf" +ynh_add_config --template="WEB.conf.default" --destination="/home/yunohost.app/$app/.config/UMS/WEB.conf" +ynh_add_config --template="VirtualFolders.conf.default" --destination="/home/yunohost.app/$app/.config/UMS/VirtualFolders.conf" +chown -R $app:$app "/home/yunohost.app/$app/.config" +chmod -R 700 "/home/yunohost.app/$app/.config" +#chmod 600 "/home/yunohost.app/$app/.config/UMS/*" #================================================= # GENERIC FINALIZATION diff --git a/scripts/remove b/scripts/remove index 8813393..4156943 100755 --- a/scripts/remove +++ b/scripts/remove @@ -108,7 +108,7 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh # Delete a system user ynh_system_user_delete --username=$app -ynh_secure_remove --file="/home/$app" +ynh_secure_remove --file="/home/yunohost.app/$app" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 40ecfa4..2c77c03 100755 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_script_progression --message="Recreating the dedicated system user..." --wei # Create the dedicated user (if not existing) #UMS require a home path for the user as config files are stored in there -ynh_system_user_create --username=$app --home_dir=/home/$app +ynh_system_user_create --username=$app --home_dir=/home/yunohost.app/$app #================================================= #SETTING MULTIMEDIA DIRECTORY @@ -125,9 +125,9 @@ yunohost service add $app --description="A DLNA, UPnP and HTTP(S) Media Server." # RESTORE VARIOUS FILES #================================================= mkdir -p /var/log/$app -ynh_restore_file --origin_path="/home/$app/" -chown -R $app:$app "/home/$app/.config" -chmod -R 700 "/home/$app/.config" +ynh_restore_file --origin_path="/home/yunohost.app/$app/" +chown -R $app:$app "/home/yunohost.app/$app/.config" +chmod -R 700 "/home/yunohost.app/$app/.config" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 9f7e915..bcd85fc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,12 +29,6 @@ upstream_version=$(ynh_app_upstream_version) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -49,6 +43,19 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +#move home folder from previous /home/app to /home/yunohost.app/$app +#has to be after backup, otherwise backup will not find home folder and will fail +if [ ! $(getent passwd $app | cut -d: -f6 | grep yunohost.app) ] +then + ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + usermod -m -d /home/yunohost.app/$app $app +fi + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -94,7 +101,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=/home/$app +ynh_system_user_create --username=$app --home_dir=/home/yunohost.app/$app #================================================= # SPECIFIC UPGRADE