From c4380aee01fe03be103e3549c582590672ac27e9 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:55:33 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- conf/.env | 2 +- conf/systemd.service | 2 +- manifest.toml | 3 ++- scripts/_common.sh | 14 +---------- scripts/backup | 23 ++++++------------ scripts/change_url | 34 +++++++++----------------- scripts/install | 46 +++++++++++++++-------------------- scripts/remove | 18 +++++--------- scripts/restore | 42 +++++++++++++------------------- scripts/upgrade | 58 ++++++++++++++++++-------------------------- 10 files changed, 89 insertions(+), 153 deletions(-) diff --git a/conf/.env b/conf/.env index 7198df0..e922483 100644 --- a/conf/.env +++ b/conf/.env @@ -8,7 +8,7 @@ NODE_ENV=production WRITABLE_PATH=__INSTALL_DIR__ # The path to NODEJS -__YNH_NODE_LOAD_PATH__ +PATH=__PATH_WITH_NODEJS__ #--------------------------------------------- # Debug OIDC OAuth2 etc. #DEBUG=true diff --git a/conf/systemd.service b/conf/systemd.service index 148183a..f9d7608 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,7 +9,7 @@ User=__APP__ Group=__APP__ EnvironmentFile=__INSTALL_DIR__/.env WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__YNH_NODE__ __INSTALL_DIR__/main.js +ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/main.js Restart=on-failure SuccessExitStatus=143 #RestartSec=10 diff --git a/manifest.toml b/manifest.toml index de8083f..05740fb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ admindoc = "https://github.com/wekan/wekan/wiki" code = "https://github.com/wekan/wekan" [integration] -yunohost = ">= 11.2.20" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = ["amd64"] multi_instance = true diff --git a/scripts/_common.sh b/scripts/_common.sh index 04438b0..8a39b2d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,20 +1,8 @@ #!/bin/bash #================================================= -# COMMON VARIABLES +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= nodejs_version="14" mongo_version="7.0" - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index a67eaaf..a0087cd 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,43 +1,34 @@ #!/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" -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" #================================================= # BACKUP THE MONGODB DATABASE #================================================= -ynh_print_info --message="Backing up the MongoDB database..." +ynh_print_info "Backing up the MongoDB database..." -ynh_mongo_dump_db --database="$db_name" > ./dump.bson +ynh_mongo_dump_db > ./dump.bson #================================================= # 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 7614f0b..96aa3e0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,52 +1,42 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # 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 #================================================= # SPECIFIC MODIFICATIONS #================================================= # MODIFY URL IN .ENV #================================================= -ynh_script_progression --message="Updating .env configuration..." +ynh_script_progression "Updating .env configuration..." -ynh_backup_if_checksum_is_different --file="$install_dir/.env" -ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$install_dir/.env" -ynh_store_file_checksum --file="$install_dir/.env" +ynh_backup_if_checksum_is_different "$install_dir/.env" +ynh_replace --match="$old_domain$old_path" --replace="$new_domain$new_path" --file="$install_dir/.env" +ynh_store_file_checksum "$install_dir/.env" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Enabling LDAP Background Sync" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Enabling LDAP Background Sync" -#if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +#if ynh_in_ci_tests; then # sleep 60 #fi @@ -54,4 +44,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin # 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 7898dcf..7e3ed4e 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 @@ -14,44 +8,42 @@ main_domain=$(cat /etc/yunohost/current_host) #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression "Installing dependencies..." -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs +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" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$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:$app "$install_dir" #================================================= # CREATE A MONGODB DATABASE #================================================= -ynh_script_progression --message="Creating a MongoDB database..." +ynh_script_progression "Creating a MongoDB database..." db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_app_setting_set --key=db_name --value=$db_name -ynh_install_mongo --mongo_version=$mongo_version +ynh_install_mongo ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression "Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app.log" @@ -60,22 +52,22 @@ yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a config file..." +ynh_script_progression "Adding a config file..." -ynh_add_config --template=".env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.env" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Enabling LDAP Background Sync" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Enabling LDAP Background Sync" -#if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +#if ynh_in_ci_tests; then # sleep 60 #fi @@ -83,4 +75,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin # 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 26100a7..d394f94 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -16,27 +10,27 @@ source /usr/share/yunohost/helpers #================================================= # 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 +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." + ynh_script_progression "Removing $app service integration..." yunohost service remove $app fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove a database if it exists, along with the associated user ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name ynh_remove_mongo # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove metapackage and its dependencies -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 389d031..868f327 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,51 +1,43 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # 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:$app "$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:$app "$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression "Reinstalling dependencies..." # Define and install dependencies -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs +ynh_nodejs_install #================================================= # RESTORE THE MONGODB DATABASE #================================================= -ynh_script_progression --message="Restoring the MongoDB database..." +ynh_script_progression "Restoring the MongoDB database..." -ynh_install_mongo --mongo_version=$mongo_version -ynh_mongo_restore_db --database="$db_name" < ./dump.bson +ynh_install_mongo +ynh_mongo_restore_db < ./dump.bson #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression "Restoring the NGINX web server configuration..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app.log" @@ -53,18 +45,18 @@ yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Enabling LDAP Background Sync" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Enabling LDAP Background Sync" -#if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +#if ynh_in_ci_tests; then # sleep 60 #fi -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 b24d7d5..b5352fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,93 +1,81 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers main_domain=$(cat /etc/yunohost/current_host) -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." # If mongo_version doesn't exist, create it if [ -z "$mongo_version" ]; then mongo_version="$(mongod --version | grep -oP 'db version v\K.{0,3}')" - ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version + ynh_app_setting_set --key=mongo_version --value=$mongo_version fi -ynh_secure_remove --file="/etc/apt/sources.list.d/mongodb-org-3.2.list" -ynh_secure_remove --file="/etc/apt/sources.list.d/mongodb-org-4.4.list" +ynh_safe_rm "/etc/apt/sources.list.d/mongodb-org-3.2.list" +ynh_safe_rm "/etc/apt/sources.list.d/mongodb-org-4.4.list" #================================================= # 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" --keep=".env" -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$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:$app "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression "Upgrading dependencies..." -ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs +ynh_nodejs_install -ynh_install_mongo --mongo_version=$mongo_version +ynh_install_mongo #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app.log" -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression "Updating configuration..." -ynh_add_config --template=".env" --destination="$install_dir/.env" +ynh_config_add --template=".env" --destination="$install_dir/.env" -chmod 400 "$install_dir/.env" -chown $app:$app "$install_dir/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/.env" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$install_dir/.env" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Enabling LDAP Background Sync" +ynh_systemctl --service=$app --action="start" --log_path=systemd --wait_until="Enabling LDAP Background Sync" -#if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then +#if ynh_in_ci_tests; then # sleep 60 #fi @@ -95,4 +83,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"