From 545a7e05689e962b535cf6622f8c5e9d72e1786c Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:46:48 +0200 Subject: [PATCH 1/2] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + manifest.toml | 4 +++- scripts/_common.sh | 14 +------------- scripts/backup | 17 ++++------------- scripts/change_url | 16 ++++------------ scripts/install | 20 +++++++------------- scripts/remove | 12 +++--------- scripts/restore | 25 ++++++++----------------- scripts/upgrade | 31 ++++++++++++------------------- 9 files changed, 43 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index 783a4ae..8f144f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.sw[op] +.DS_Store diff --git a/manifest.toml b/manifest.toml index f2b0295..4793598 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,8 @@ code = "https://github.com/gchq/CyberChef" cpe = "cpe:2.3:a:gchq:cyberchef" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false @@ -54,6 +55,7 @@ ram.runtime = "20M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 90a8642..96517a1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,32 +1,23 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index f89e64a..b69b5e5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,27 +1,19 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upstream_source_url=$(ynh_read_manifest --manifest_key="resources.sources.main.url") +upstream_source_url=$(ynh_read_manifest index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf -#================================================= -# STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 7f79b93..855fefa 100755 --- a/scripts/install +++ b/scripts/install @@ -1,15 +1,9 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upstream_source_url=$(ynh_read_manifest --manifest_key="resources.sources.main.url") +upstream_source_url=$(ynh_read_manifest source_filename=$(basename $upstream_source_url) index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf @@ -18,20 +12,20 @@ index_page=$(basename -s .zip $upstream_source_url).html #this variable will als #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=10 +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" -ynh_replace_string --match_string="$source_filename" --replace_string="$upstream_source_url" --target_file="$install_dir/$index_page" #replace link to local source file with link to upstream source file -chown -R $app:www-data "$install_dir" +ynh_replace --match="$source_filename" --replace="$upstream_source_url" --file="$install_dir/$index_page" #replace link to local source file with link to upstream source file +#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:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app ..." --weight=4 +ynh_script_progression "Adding system configurations related to $app ..." -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index d66115e..4c1e198 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,22 +1,16 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index c9a3303..68e80e9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,29 +7,26 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chown -R $app:www-data "$install_dir" +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 | chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression "Reloading NGINX web server..." -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 8c53ddc..3502e87 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,17 +1,9 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) - -upstream_source_url=$(ynh_read_manifest --manifest_key="resources.sources.main.url") +upstream_source_url=$(ynh_read_manifest source_filename=$(basename $upstream_source_url) index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf @@ -21,25 +13,26 @@ index_page=$(basename -s .zip $upstream_source_url).html #this variable will als # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed +if ynh_app_upstream_version_changed then - ynh_script_progression --message="Upgrading source files..." --weight=10 - ynh_setup_source --dest_dir="$install_dir" --full_replace=1 - ynh_replace_string --match_string="$source_filename" --replace_string="$upstream_source_url" --target_file="$install_dir/$index_page" #replace link to local source file with link to upstream source file - chown -R $app:www-data "$install_dir" + ynh_script_progression "Upgrading source files..." + ynh_setup_source --dest_dir="$install_dir" --full_replace + ynh_replace --match="$source_filename" --replace="$upstream_source_url" --file="$install_dir/$index_page" #replace link to local source file with link to upstream source file + + #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:www-data "$install_dir" fi -chown -R $app:www-data "$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:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=4 +ynh_script_progression "Upgrading system configurations related to $app..." -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" From 751fc36cfc848d7c13eb38992283a61bc39132d1 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 14:13:21 +0200 Subject: [PATCH 2/2] cleaning --- manifest.toml | 2 +- scripts/change_url | 2 +- scripts/install | 3 +-- scripts/restore | 2 -- scripts/upgrade | 17 +++++------------ 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/manifest.toml b/manifest.toml index 4793598..2c359fb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,7 @@ code = "https://github.com/gchq/CyberChef" cpe = "cpe:2.3:a:gchq:cyberchef" [integration] -yunohost = ">= 11.2.18" +yunohost = ">= 11.2.29" helpers_version = "2.1" architectures = "all" multi_instance = true diff --git a/scripts/change_url b/scripts/change_url index b69b5e5..803beb5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -3,7 +3,7 @@ source _common.sh source /usr/share/yunohost/helpers -upstream_source_url=$(ynh_read_manifest +upstream_source_url=$(ynh_read_manifest) index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf #================================================= diff --git a/scripts/install b/scripts/install index 855fefa..7f2d19b 100755 --- a/scripts/install +++ b/scripts/install @@ -3,7 +3,7 @@ source _common.sh source /usr/share/yunohost/helpers -upstream_source_url=$(ynh_read_manifest +upstream_source_url=$(ynh_read_manifest) source_filename=$(basename $upstream_source_url) index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf @@ -17,7 +17,6 @@ ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" ynh_replace --match="$source_filename" --replace="$upstream_source_url" --file="$install_dir/$index_page" #replace link to local source file with link to upstream source file -#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:www-data "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 68e80e9..37c5d8f 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,6 +1,5 @@ #!/bin/bash -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -11,7 +10,6 @@ ynh_script_progression "Restoring the 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 | chown -R $app:www-data "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3502e87..0ab696f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,7 +3,7 @@ source _common.sh source /usr/share/yunohost/helpers -upstream_source_url=$(ynh_read_manifest +upstream_source_url=$(ynh_read_manifest) source_filename=$(basename $upstream_source_url) index_page=$(basename -s .zip $upstream_source_url).html #this variable will also populate the template tag __INDEX_PAGE__ in nginx.conf @@ -12,18 +12,11 @@ index_page=$(basename -s .zip $upstream_source_url).html #this variable will als #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression "Upgrading source files..." + +ynh_setup_source --dest_dir="$install_dir" --full_replace +ynh_replace --match="$source_filename" --replace="$upstream_source_url" --file="$install_dir/$index_page" #replace link to local source file with link to upstream source file -# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed -if ynh_app_upstream_version_changed -then - ynh_script_progression "Upgrading source files..." - ynh_setup_source --dest_dir="$install_dir" --full_replace - ynh_replace --match="$source_filename" --replace="$upstream_source_url" --file="$install_dir/$index_page" #replace link to local source file with link to upstream source file - - #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:www-data "$install_dir" -fi - -#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:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #=================================================