diff --git a/manifest.json b/manifest.json index 8bee975..33c3984 100644 --- a/manifest.json +++ b/manifest.json @@ -16,7 +16,7 @@ }, "multi_instance": true, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "services": [ "nginx" diff --git a/scripts/install b/scripts/install index 94fd0d8..bd9aaae 100644 --- a/scripts/install +++ b/scripts/install @@ -69,6 +69,14 @@ ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -78,6 +86,11 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod +x $final_path/bin/runSafe.sh + #================================================= # NGINX CONFIGURATION #================================================= @@ -86,14 +99,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # INSTALL ETHERCALC #================================================= @@ -116,14 +121,6 @@ ynh_replace_string --match_string="__EXPIRE__" --replace_string="$expire" --targ ynh_add_systemd_config -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chown -R $app: $final_path -chmod 755 $final_path -chmod +x $final_path/bin/runSafe.sh - #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= diff --git a/scripts/restore b/scripts/restore index 43d132f..a8c5c9b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -51,6 +51,14 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -58,20 +66,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R root: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod +x $final_path/bin/runSafe.sh #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 3788a81..99f4fc2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,6 +67,14 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=3 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -79,6 +87,11 @@ then ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod +x $final_path/bin/runSafe.sh + #================================================= # NGINX CONFIGURATION #================================================= @@ -97,14 +110,6 @@ ynh_install_app_dependencies $pkg_dependencies # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # INSTALL ETHERCALC #================================================= @@ -115,15 +120,6 @@ pushd "$final_path" ynh_exec_warn_less npm install -g ethercalc popd -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R $app: $final_path - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================