diff --git a/scripts/_common.sh b/scripts/_common.sh index 277549b..e1c34d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,3 +7,15 @@ YNH_PHP_VERSION="7.3" extra_php_dependencies="php-geoip php${YNH_PHP_VERSION}-cli" lang="fr_FR.UTF-8 en_US.UTF-8 it_IT.UTF-8" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install index 2b0d1a6..7503b19 100644 --- a/scripts/install +++ b/scripts/install @@ -62,6 +62,14 @@ done locale-gen +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= #INSTALL SOURCES #=============================================== @@ -77,9 +85,9 @@ ln -s $final_path/lang/fr $final_path/lang/fr_FR ln -s $final_path/lang/it $final_path/lang/it_IT ln -s $final_path/www/template-exemple $final_path/template-exemple -#chmod 750 "$final_path" -#chmod -R o-rwx "$final_path" -#chown -R $app:www-data "$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # CREATE A MYSQL DATABASE @@ -109,7 +117,6 @@ yunohost tools regen-conf postfix #create the virtual aliases file touch $final_path/var/virtual postmap $final_path/var/virtual -chown -R www-data:www-data $final_path #create an alias for deleted junk adresses cp /etc/aliases /etc/aliases.emailpoubelle.bak #backup it diff --git a/scripts/remove b/scripts/remove index bb090c4..174218c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -85,4 +85,16 @@ yunohost tools regen-conf postfix ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=postfix --action=reload -ynh_script_progression --message="Removal of $app completed" +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." + +# Delete a system user +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index ac8e557..b68e82b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,6 +48,14 @@ test ! -d $final_path \ ynh_restore_file "/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 #================================================= @@ -55,6 +63,10 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -106,7 +118,7 @@ fi #================================================= ynh_script_progression --message="Reinstall cron job" --weight=1 -ynh_restore_file "/etc/cron.d/$app" +ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 54c1bbd..3e8c2b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,6 +67,14 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +#================================================= +# CREATE DEDICATED USER +#================================================= +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="$final_path" + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -112,11 +120,9 @@ cp -R ../sources/hooks/conf_regen/98-postfix_emailpoubelle /usr/share/yunohost/h mv /etc/postfix/main.cf /etc/postfix/main.cf.emailpoubelle.bak yunohost tools regen-conf postfix -f -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chown -R www-data:www-data $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RELOAD SERVICES