From e487cfaa3d42f918e6d42ff1984cbfaff703a4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 23:31:26 +0100 Subject: [PATCH] finalize port --- scripts/backup | 10 ++++++++-- scripts/change_url | 9 ++++----- scripts/remove | 2 +- scripts/restore | 27 ++++++++++----------------- scripts/upgrade | 27 ++++++++++++++++----------- 5 files changed, 39 insertions(+), 36 deletions(-) diff --git a/scripts/backup b/scripts/backup index d1816f1..289c38f 100755 --- a/scripts/backup +++ b/scripts/backup @@ -21,16 +21,22 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$data_dir" + #================================================= # SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/logrotate.d/$app" - ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP VARIOUS FILES #================================================= diff --git a/scripts/change_url b/scripts/change_url index d5b0639..b7bcef0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,12 +30,10 @@ ynh_change_url_nginx_config #================================================= # UPDATE CONFIGURATION FILE #================================================= -#REMOVEME? -path=$new_path -ynh_exec_warn_less ynh_add_config --template="../conf/config.xml" --destination="$install_dir/config.xml" +ynh_exec_warn_less ynh_add_config --template="config.xml" --destination="$data_dir/config.xml" -chown $app:$app "$install_dir/config.xml" +chown "$app:$app" "$data_dir/config.xml" #================================================= # GENERIC FINALISATION @@ -44,7 +42,8 @@ chown $app:$app "$install_dir/config.xml" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting Web Server" +# Start a systemd service +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 23788df..8999ab4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,7 +16,7 @@ ynh_script_progression --message="Removing system configurations related to $app # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then - yunohost service remove "$app" + yunohost service remove "$app" fi # Remove the dedicated systemd config diff --git a/scripts/restore b/scripts/restore index 7449e28..cc68b8e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,14 +15,19 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=2 -# Remove the version installed by the deb package -ynh_secure_remove "$install_dir" ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R "$app:$app" "$install_dir" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +chown -R "$app:$app" "$data_dir" + #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= @@ -59,22 +64,10 @@ ynh_restore_file --origin_path="/var/log/$app/" #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 - -# If a first Sonarr app was running before installing this one, -# it may have been stopped by the installation of the dependencies. -# Let's restart it. -if ! systemctl is-active "$app.service"; then - ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 -fi +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30 ynh_systemd_action --service_name=nginx --action=reload - -ynh_exec_warn ls -lah "$install_dir" -ynh_exec_warn cat "$install_dir/config.xml" -ynh_exec_warn cat "/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index dbd6182..532baed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,12 +23,24 @@ ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -if [ -d "$install_dir/logs" ]; then +if [ -d "$data_dir/logs" ]; then ynh_secure_remove --file="/var/log/$app" - mv "$install_dir/logs" "/var/log/$app" - ln -s "/var/log/$app" "$install_dir/logs" + mv "$data_dir/logs" "/var/log/$app" + ln -s "/var/log/$app" "$data_dir/logs" fi +#================================================= +# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 + +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 + +chown -R "$app:$app" "$install_dir" + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= @@ -49,14 +61,7 @@ ynh_use_logrotate --non-append --logfile="/var/log/$app/" #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 - -# If a first Sonarr app was running before installing this one, -# it may have been stopped by the installation of the dependencies. -# Let's restart it. (hence why we use sonarr and not $app..) -if ! systemctl -q is-active sonarr; then - ynh_exec_fully_quiet ynh_systemd_action --service_name=sonarr --action="restart" --log_path="systemd" --line_match="Starting Web Server" --timeout=30 -fi +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Application started." --timeout=30 #================================================= # END OF SCRIPT