From 0768f57e67b30907693e7ab014853119b0d34409 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:02:09 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .gitignore | 1 + manifest.toml | 4 ++- scripts/_common.sh | 16 ++-------- scripts/backup | 17 +++-------- scripts/change_url | 18 ++++-------- scripts/install | 56 +++++++++++++++-------------------- scripts/remove | 16 ++++------ scripts/restore | 32 ++++++++------------ scripts/upgrade | 73 +++++++++++++++++++++------------------------- 9 files changed, 89 insertions(+), 144 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 281398f..2c411da 100644 --- a/manifest.toml +++ b/manifest.toml @@ -20,7 +20,8 @@ userdoc = "https://standardnotes.org/help" code = "https://github.com/standardnotes/app" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = true @@ -61,6 +62,7 @@ ram.runtime = "1500M" [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 43b7307..7f935b4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,21 +1,9 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= -NODEJS_VERSION="16" +nodejs_version="16" node_max_old_space_size=2048 - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================ -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index 52eea5b..af443d9 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,34 +1,25 @@ #!/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 -#================================================= -# 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 fa9c8dd..e4bf547 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,33 +1,25 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# 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 #================================================= # SPECIFIC MODIFICATIONS #================================================= -ynh_script_progression --message="Modify Configuration..." --weight=1 +ynh_script_progression "Modify Configuration..." if [ $change_path -eq 1 ]; then cp "$install_dir/live/packages/web/dist/app.js.orginal" "$install_dir/live/packages/web/dist/app.js" # If $new_path is used modify .js file for a working app on a subpath if [ $new_path != "/" ]; then - ynh_replace_string --match_string="/components/" --replace_string="$new_path/components/" --target_file="$install_dir/live/packages/web/dist/app.js" + ynh_replace --match="/components/" --replace="$new_path/components/" --file="$install_dir/live/packages/web/dist/app.js" fi fi @@ -35,4 +27,4 @@ fi # 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 93ad60b..1ef9214 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -15,72 +9,70 @@ source /usr/share/yunohost/helpers if [ -z "$snserver_domain" ]; then snserver_domain="api.standardnotes.com" - ynh_app_setting_set --app="$app" --key=snserver_domain --value="$snserver_domain" + ynh_app_setting_set --key=snserver_domain --value="$snserver_domain" fi #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Installing NodeJS..." --weight=30 +ynh_script_progression "Installing NodeJS..." -ynh_install_nodejs --nodejs_version="$NODEJS_VERSION" +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=16 +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/live" -chmod 750 "$install_dir" -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 750 "$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" #================================================= # BUILDING #================================================= -ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #497 +ynh_script_progression "Building... ( This may take a while... )" #497 pushd "$install_dir/live" - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as "$app" env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn install --immutable - ynh_exec_warn_less ynh_exec_as "$app" env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn build:web + + ynh_hide_warnings ynh_exec_as_app NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" node_load_PATH" yarn install --immutable + ynh_hide_warnings ynh_exec_as_app NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" node_load_PATH" yarn build:web popd -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" #================================================= # Modify Config #================================================= -ynh_script_progression --message="Configuring..." --weight=1 +ynh_script_progression "Configuring..." # If $path is used modify .js file for a working app on a subpath cp "$install_dir/live/packages/web/dist/app.js" "$install_dir/live/packages/web/dist/app.js.orginal" if [ "$path" != "/" ]; then - ynh_replace_string --match_string="/components/" --replace_string="$path/components/" --target_file="$install_dir/live/packages/web/dist/app.js" + ynh_replace --match="/components/" --replace="$path/components/" --file="$install_dir/live/packages/web/dist/app.js" fi # Modify Config index_file="$install_dir/live/packages/web/dist/index.html" -ynh_replace_string --match_string="\(defaultSyncServer = \).*" --replace_string="\1\"https://$snserver_domain\"" --target_file="$index_file" -ynh_replace_string --match_string="\(defaultFilesHost = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(enabledUnfinishedFeatures = \).*" --replace_string="\1false" --target_file="$index_file" -ynh_replace_string --match_string="\(websocketUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(purchaseUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(plansUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(dashboardUrl =\).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace --match="\(defaultSyncServer = \).*" --replace="\1\"https://$snserver_domain\"" --file="$index_file" +ynh_replace --match="\(defaultFilesHost = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(enabledUnfinishedFeatures = \).*" --replace="\1false" --file="$index_file" +ynh_replace --match="\(websocketUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(purchaseUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(plansUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(dashboardUrl =\).*" --replace="\1\"\"" --file="$index_file" #================================================= # 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" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e8d77f3..07a3b4e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,31 +1,25 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE NODEJS #================================================= -ynh_script_progression --message="Removing NodeJS..." --weight=4 +ynh_script_progression "Removing NodeJS..." -ynh_remove_nodejs +ynh_nodejs_remove #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression "Removing NGINX web server configuration..." # Remove the dedicated NGINX config -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 8d7941a..04016e1 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,38 +7,36 @@ source /usr/share/yunohost/helpers #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Reinstalling NodeJS..." --weight=30 +ynh_script_progression "Reinstalling NodeJS..." -ynh_install_nodejs --nodejs_version="$NODEJS_VERSION" +ynh_nodejs_install #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=2 - -ynh_restore_file --origin_path="$install_dir" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:www-data" "$install_dir" +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 | chmod 750 "$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 #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +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 0a77a0b..3600c38 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,100 +1,93 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." +# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=snserver_domain --value="api.standardnotes.com" if [ -z "${snserver_domain:-}" ]; then snserver_domain="api.standardnotes.com" - ynh_app_setting_set --app="$app" --key=snserver_domain --value="$snserver_domain" + ynh_app_setting_set --key=snserver_domain --value="$snserver_domain" fi -if ynh_compare_current_package_version --comparison lt --version 3.66.0~ynh1; then +if ynh_app_upgrading_from_version_before 3.66.0~ynh1; then # Remove old service - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression "Removing $app service..." yunohost service remove "$app" - ynh_remove_systemd_config --service="$app" + ynh_config_remove_systemd # Remove unneeded ruby - ynh_remove_ruby - ynh_secure_remove --file="$install_dir/.bundle" - ynh_secure_remove --file="$install_dir/.ruby-version" + ynh_ruby_remove + ynh_safe_rm "$install_dir/.bundle" + ynh_safe_rm "$install_dir/.ruby-version" fi #================================================= # INSTALL NODEJS #================================================= -ynh_script_progression --message="Upgrading NodeJS..." --weight=30 +ynh_script_progression "Upgrading NodeJS..." -ynh_install_nodejs --nodejs_version="$NODEJS_VERSION" +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=17 +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1 +ynh_setup_source --dest_dir="$install_dir/live" --full_replace # Set permissions to app files -chmod 750 "$install_dir" -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 750 "$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" #================================================= # BUILDING #================================================= -ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #131 +ynh_script_progression "Building... ( This may take a while... )" #131 pushd "$install_dir/live" - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as "$app" env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn install --immutable - ynh_exec_warn_less ynh_exec_as "$app" env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" "$ynh_node_load_PATH" yarn build:web + + ynh_hide_warnings ynh_exec_as_app NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" node_load_PATH" yarn install --immutable + ynh_hide_warnings ynh_exec_as_app NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" node_load_PATH" yarn build:web popd -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" #================================================= # Modify Config #================================================= -ynh_script_progression --message="Configuring..." --weight=1 +ynh_script_progression "Configuring..." # If $path is used modify .js file for a working app on a subpath cp "$install_dir/live/packages/web/dist/app.js" "$install_dir/live/packages/web/dist/app.js.orginal" if [ "$path" != "/" ]; then - ynh_replace_string --match_string="/components/" --replace_string="$path/components/" --target_file="$install_dir/live/packages/web/dist/app.js" + ynh_replace --match="/components/" --replace="$path/components/" --file="$install_dir/live/packages/web/dist/app.js" fi # Modify Config index_file="$install_dir/live/packages/web/dist/index.html" -ynh_replace_string --match_string="\(defaultSyncServer = \).*" --replace_string="\1\"https://$snserver_domain\"" --target_file="$index_file" -ynh_replace_string --match_string="\(defaultFilesHost = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(enabledUnfinishedFeatures = \).*" --replace_string="\1false" --target_file="$index_file" -ynh_replace_string --match_string="\(websocketUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(purchaseUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(plansUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" -ynh_replace_string --match_string="\(dashboardUrl =\).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace --match="\(defaultSyncServer = \).*" --replace="\1\"https://$snserver_domain\"" --file="$index_file" +ynh_replace --match="\(defaultFilesHost = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(enabledUnfinishedFeatures = \).*" --replace="\1false" --file="$index_file" +ynh_replace --match="\(websocketUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(purchaseUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(plansUrl = \).*" --replace="\1\"\"" --file="$index_file" +ynh_replace --match="\(dashboardUrl =\).*" --replace="\1\"\"" --file="$index_file" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading 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" --last +ynh_script_progression "Upgrade of $app completed"