From 56172216e5ba7af1ef9096aa4f8ea102c6cf3884 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:55:50 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 4 +++- scripts/_common.sh | 42 +++++++++++++++--------------------------- scripts/backup | 11 ++++------- scripts/change_url | 10 +++++----- scripts/install | 21 ++++++++++----------- scripts/remove | 8 ++++---- scripts/restore | 23 +++++++++++------------ scripts/upgrade | 23 +++++++++++------------ 8 files changed, 63 insertions(+), 79 deletions(-) diff --git a/manifest.toml b/manifest.toml index 7ddd6c6..93618b0 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ website = "https://framagit.org/framasoft/framagames" code = "https://framagit.org/framasoft/framagames" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false @@ -49,6 +50,7 @@ ram.runtime = "50M" [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 2f20db9..b242c4f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,50 +1,38 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= nodejs_version=12 -#================================================= -# PERSONAL HELPERS -#================================================= - _configure_framagames() { - ynh_replace_string --target_file="$install_dir/sources/src/data/main.yml" \ - --match_string="canonical: .*" \ - --replace_string="canonical: https://$domain$path" + ynh_replace --file="$install_dir/sources/src/data/main.yml" \ + --match="canonical: .*" \ + --replace="canonical: https://$domain$path" - ynh_replace_string --target_file="$install_dir/sources/src/data/main.yml" \ - --match_string="framanav: true" \ - --replace_string="framanav: false" + ynh_replace --file="$install_dir/sources/src/data/main.yml" \ + --match="framanav: true" \ + --replace="framanav: false" # %/ is here to prevent double slash when path is / - ynh_replace_string --target_file="$install_dir/sources/config/env.js" \ - --match_string=" basepath:.*" \ - --replace_string=" basepath: '${path%/}/', wrong_path: false" + ynh_replace --file="$install_dir/sources/config/env.js" \ + --match=" basepath:.*" \ + --replace=" basepath: '${path%/}/', wrong_path: false" } _build_install_framagames() { pushd "$install_dir/sources" - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run commons - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run prod + + ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run commons + ynh_hide_warnings ynh_exec_as_app node_load_PATH" npm run prod popd - ynh_secure_remove --file="$install_dir/www" + ynh_safe_rm "$install_dir/www" mv -f "$install_dir/sources/dist" "$install_dir/www" cp -r "$install_dir/sources/games/"* "$install_dir/www" if [[ "$path" != "/" ]]; then mv -f "$install_dir/www/$path/"* "$install_dir/www" 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" } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 342aced..27f2595 100755 --- a/scripts/backup +++ b/scripts/backup @@ -8,25 +8,22 @@ 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 6348524..ee8cd36 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -10,21 +10,21 @@ source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # CONFIGURE APP #================================================= -ynh_script_progression --message="Configuring $app..." +ynh_script_progression "Configuring $app..." _configure_framagames #================================================= # BUILD APP #================================================= -ynh_script_progression --message="Building $app..." +ynh_script_progression "Building $app..." _build_install_framagames @@ -32,4 +32,4 @@ _build_install_framagames # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 6089329..4ef142d 100644 --- a/scripts/install +++ b/scripts/install @@ -10,45 +10,44 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=1 +ynh_script_progression "Installing NodeJS..." -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/sources" -chmod -R o-rwx "$install_dir" -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 | 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:www-data" "$install_dir" #================================================= # CONFIGURE APP #================================================= -ynh_script_progression --message="Configuring $app..." +ynh_script_progression "Configuring $app..." _configure_framagames #================================================= # BUILD APP #================================================= -ynh_script_progression --message="Building $app..." +ynh_script_progression "Building $app..." _build_install_framagames #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 1ff8aa3..4e1a8db 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,14 +10,14 @@ 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 -ynh_remove_nodejs +ynh_nodejs_remove #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 7016c53..e7a089e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -11,36 +11,35 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Restoring NodeJS..." --weight=1 +ynh_script_progression "Restoring NodeJS..." -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_nodejs_install #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod -R o-rwx "$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 | 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: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" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression "Reloading NGINX web server and PHP-FPM..." -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" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 3430951..ff8b4ac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,45 +10,44 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Updating NodeJS..." --weight=1 +ynh_script_progression "Updating NodeJS..." -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 - -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +ynh_setup_source --dest_dir="$install_dir/sources" --full_replace +#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:www-data" "$install_dir" #================================================= # CONFIGURE APP #================================================= -ynh_script_progression --message="Configuring $app..." +ynh_script_progression "Configuring $app..." _configure_framagames #================================================= # BUILD APP #================================================= -ynh_script_progression --message="Building $app..." +ynh_script_progression "Building $app..." _build_install_framagames #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"