From fb1b7aa2ddc3e2e18dad2ff39cd633d95ccbf8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 5 Feb 2024 13:26:38 +0100 Subject: [PATCH] Cleanup packagingv2, fix patch --- manifest.toml | 8 ++-- scripts/backup | 16 ++------ scripts/change_url | 2 +- scripts/install | 23 ++++------- scripts/remove | 11 ++--- scripts/restore | 12 ++---- scripts/upgrade | 40 +++++-------------- ...-server.py.patch => main-fix-python.patch} | 0 8 files changed, 34 insertions(+), 78 deletions(-) rename sources/patches/{app-00-grammalecte-server.py.patch => main-fix-python.patch} (100%) diff --git a/manifest.toml b/manifest.toml index 1ec8366..969a3fe 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,10 +32,10 @@ ram.runtime = "50M" full_domain = true [resources] - [resources.sources.main] - url = "https://grammalecte.net/zip/Grammalecte-fr-v2.1.1.zip" - sha256 = "f643eca603652469947d9bd85fb0ec08f8eb0f7b6ab925d2fb18bfc6fdd8d21c" - in_subdir = false + [resources.sources.main] + url = "https://grammalecte.net/zip/Grammalecte-fr-v2.1.1.zip" + sha256 = "f643eca603652469947d9bd85fb0ec08f8eb0f7b6ab925d2fb18bfc6fdd8d21c" + in_subdir = false [resources.ports] diff --git a/scripts/backup b/scripts/backup index f585e19..dbafeec 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,31 +22,21 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup --src_path="/etc/systemd/system/$app.service" + #================================================= # BACKUP LOGS #================================================= ynh_backup --src_path="/var/log/$app" -#================================================= -# BACKUP SYSTEMD -#================================================= - -ynh_backup --src_path="/etc/systemd/system/$app.service" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index c22eb4f..244b966 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,7 +32,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 8671121..4ca4d41 100755 --- a/scripts/install +++ b/scripts/install @@ -17,10 +17,14 @@ ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" +# Set permissions to app files +chmod u+x "$install_dir/grammalecte-server.py" +chown -R "$app:www-data" "$install_dir" + #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -31,18 +35,7 @@ ynh_add_systemd_config # Use logrotate to manage application logfile(s) ynh_use_logrotate -yunohost service add $app --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R root:$app $install_dir -chmod u+x $install_dir/grammalecte-server.py -chmod -R g=u,g-w,o-rwx $install_dir +yunohost service add "$app" --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -50,7 +43,7 @@ chmod -R g=u,g-w,o-rwx $install_dir ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 3a1171c..3643460 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,16 +10,13 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi # Remove the dedicated systemd config diff --git a/scripts/restore b/scripts/restore index 23087b8..f6773a7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -17,10 +17,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -# Restore permissions on app files -chown -R root:$app $install_dir -chmod u+x $install_dir/grammalecte-server.py -chmod -R g=u,g-w,o-rwx $install_dir +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE SYSTEMD @@ -30,20 +27,19 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet +yunohost service add "$app" --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/var/log/$app" -yunohost service add $app --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index c5f30b0..258bae3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -24,52 +18,38 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +chmod u+x "$install_dir/grammalecte-server.py" +chown -R "$app:www-data" "$install_dir" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 - - ynh_secure_remove --file="$install_dir" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" -fi +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add "$app" --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -yunohost service add $app --description="Spelling, grammar, and typography checking server for French and Occitan" --log="/var/log/$app/$app.log" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R root:$app $install_dir -chmod u+x $install_dir/grammalecte-server.py -chmod -R g=u,g-w,o-rwx $install_dir - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/sources/patches/app-00-grammalecte-server.py.patch b/sources/patches/main-fix-python.patch similarity index 100% rename from sources/patches/app-00-grammalecte-server.py.patch rename to sources/patches/main-fix-python.patch