From 9bfbcb6ee5e6e0537324bdb7dfe6fd527e6525c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 14 Mar 2023 07:44:02 +0100 Subject: [PATCH] cleaning --- manifest.toml | 1 - scripts/install | 56 +++++++++++++++---------------------------------- scripts/remove | 18 ++++------------ scripts/restore | 33 +++++++++-------------------- scripts/upgrade | 12 +++-------- 5 files changed, 34 insertions(+), 86 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9486deb..f6da502 100644 --- a/manifest.toml +++ b/manifest.toml @@ -47,7 +47,6 @@ ram.runtime = "50M" [install.admin] type = "user" - optional = false [resources] [resources.sources.main] diff --git a/scripts/install b/scripts/install index 5b0decf..0738f1c 100755 --- a/scripts/install +++ b/scripts/install @@ -21,63 +21,41 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# PHP-FPM CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# SETUPING FRESHRSS -#================================================= -ynh_script_progression --message="FreshRSS setup script..." --weight=1 - -ynh_exec_as $app $install_dir/cli/do-install.php --default_user $admin --auth_type http_auth --environment production --base_url https://$domain$path --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_name --db-password $db_pwd --db-base $db_name - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Creating users..." --weight=1 - -for myuser in $(ynh_user_list) -do - user_token=$(ynh_string_random) - ynh_exec_as $app $install_dir/cli/create-user.php --user $myuser --language $language --token $user_token -done - -#================================================= -# SETUP A CRON -#================================================= -ynh_script_progression --message="Setting up cron..." --weight=1 - ynh_add_config --template="../conf/freshrss.cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - log_path="/var/log/$app" mkdir -p $log_path chown $app:www-data $log_path # Use logrotate to manage application logfile(s) ynh_use_logrotate +#================================================= +# SPECIFIC SETUP +#================================================= +# SETUPING FRESHRSS +#================================================= +ynh_script_progression --message="FreshRSS setup..." --weight=1 + +ynh_exec_as $app $install_dir/cli/do-install.php --default_user $admin --auth_type http_auth --environment production --base_url https://$domain$path --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user $db_name --db-password $db_pwd --db-base $db_name + +for myuser in $(ynh_user_list) +do + user_token=$(ynh_string_random) + ynh_exec_as $app $install_dir/cli/create-user.php --user $myuser --language $language --token $user_token +done + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index b7b9f80..8b41faa 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,28 +10,18 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +# REMOVE SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 1c48b5d..7ef4de0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,20 +20,6 @@ ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=5 - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE MYSQL DATABASE #================================================= @@ -42,17 +28,18 @@ ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE VARIOUS FILES +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/cron.d/$app" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - log_path="/var/log/$app" mkdir -p $log_path chown $app:www-data $log_path @@ -61,9 +48,9 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 47b5352..6ae8bcf 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,19 +22,13 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - if [ -z "$admin" ]; then -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin_user) + admin=$(ynh_app_setting_get --app=$app --key=admin_user) if [ -z $admin ]; then ynh_die --message="no admin user found" fi; ynh_app_setting_delete --app=$app --key=admin_user -#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin + ynh_app_setting_set --app=$app --key=admin --value=$admin fi #================================================= @@ -91,7 +85,7 @@ if [ -f /tmp/FreshRSS.log ]; then ynh_secure_remove --file="/tmp/FreshRSS.log" fi -if [ -f /var/www/$app/$app.log ]; then +if [ -f $install_dir/$app.log ]; then ynh_secure_remove --file="/var/www/$app/$app.log" fi