From 8573359c3984f86cb9b87db484cbf7ab274b0fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 1 Sep 2024 18:33:25 +0200 Subject: [PATCH] cleaning --- scripts/backup | 20 +------------------- scripts/install | 5 ++--- scripts/restore | 11 +---------- scripts/upgrade | 30 +++++------------------------- 4 files changed, 9 insertions(+), 57 deletions(-) diff --git a/scripts/backup b/scripts/backup index 5c2b869..3738252 100644 --- a/scripts/backup +++ b/scripts/backup @@ -18,36 +18,18 @@ ynh_backup "$install_dir" ynh_backup "$data_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= - ynh_backup "/etc/fail2ban/jail.d/$app.conf" ynh_backup "/etc/fail2ban/filter.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup "/etc/logrotate.d/$app" -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup "/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - ynh_backup "/var/log/$app" #================================================= diff --git a/scripts/install b/scripts/install index 6d76b21..721e1ec 100644 --- a/scripts/install +++ b/scripts/install @@ -13,7 +13,9 @@ source /usr/share/yunohost/helpers #================================================= # Create install and data subdirs #================================================= + ynh_setup_source --dest_dir="$install_dir" + xz -d "$install_dir/forgejo.xz" chmod +x "$install_dir/forgejo" @@ -68,9 +70,6 @@ ynh_script_progression "Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_config_add_logrotate "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod u=rwX,g=rX,o= "/var/log/$app" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/restore b/scripts/restore index acdd9ab..c67ac58 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,8 +19,6 @@ ynh_script_progression "Restoring $app main directory..." ynh_restore "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -28,13 +26,6 @@ ynh_script_progression "Restoring the data directory..." ynh_restore "$data_dir" chown -R "$app:$app" "$data_dir" -#================================================= -# RESTORE THE LOG DIRECTORY -#================================================= -ynh_restore "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod u=rwX,g=rX,o= "/var/log/$app" - #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= @@ -49,7 +40,7 @@ ynh_systemctl --action=restart --service=fail2ban #================================================= ynh_script_progression "Restoring the database..." -ynh_psql_db_shell " < "./db.sql"" +ynh_psql_db_shell < "./db.sql" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 7e00991..e1a04d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ source /usr/share/yunohost/helpers # STOP SYSTEMD SERVICE #================================================= ynh_script_progression "Stopping $app's systemd service..." + ynh_systemctl --service="$app" --action="stop" --log_path="systemd" #================================================= @@ -43,32 +44,16 @@ if [ -d "$data_dir/.ssh" ]; then fi # If secret_key doesn't exist, create it -# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=secret_key --value=$("$install_dir/forgejo" generate secret SECRET_KEY) -if [ -z "${secret_key:-}" ]; then - secret_key=$("$install_dir/forgejo" generate secret SECRET_KEY) - ynh_app_setting_set --key=secret_key --value="$secret_key" -fi +ynh_app_setting_set_default --key=secret_key --value=$("$install_dir/forgejo" generate secret SECRET_KEY) # If lfs_jwt_secret doesn't exist, create it -# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=lfs_jwt_secret --value=$("$install_dir/forgejo" generate secret JWT_SECRET) -if [ -z "${lfs_jwt_secret:-}" ]; then - lfs_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) - ynh_app_setting_set --key=lfs_jwt_secret --value="$lfs_jwt_secret" -fi +ynh_app_setting_set_default --key=lfs_jwt_secret --value=$("$install_dir/forgejo" generate secret JWT_SECRET) # If internal_token doesn't exist, create it -# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=internal_token --value=$("$install_dir/forgejo" generate secret INTERNAL_TOKEN) -if [ -z "${internal_token:-}" ]; then - internal_token=$("$install_dir/forgejo" generate secret INTERNAL_TOKEN) - ynh_app_setting_set --key=internal_token --value="$internal_token" -fi +ynh_app_setting_set_default --key=internal_token --value=$("$install_dir/forgejo" generate secret INTERNAL_TOKEN) # If oauth2_jwt_secret doesn't exist, create it -# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=oauth2_jwt_secret --value=$("$install_dir/forgejo" generate secret JWT_SECRET) -if [ -z "${oauth2_jwt_secret:-}" ]; then - oauth2_jwt_secret=$("$install_dir/forgejo" generate secret JWT_SECRET) - ynh_app_setting_set --key=oauth2_jwt_secret --value="$oauth2_jwt_secret" -fi +ynh_app_setting_set_default --key=oauth2_jwt_secret --value=$("$install_dir/forgejo" generate secret JWT_SECRET) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -78,8 +63,6 @@ ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="custom .ssh" xz -f -d "$install_dir/forgejo.xz" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" -#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir" chmod +x "$install_dir/forgejo" #================================================= @@ -115,9 +98,6 @@ ynh_script_progression "Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_config_add_logrotate "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app" -#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod u=rwX,g=rX,o= "/var/log/$app" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================