From 63134401d78057d8c9629a24c5acbe8aadeea05f Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:12:09 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 14 +------------- scripts/backup | 21 ++++++--------------- scripts/change_url | 24 +++++++----------------- scripts/install | 36 ++++++++++++++---------------------- scripts/remove | 26 ++++++++++---------------- scripts/restore | 42 +++++++++++++++++------------------------- scripts/upgrade | 32 ++++++++------------------------ 8 files changed, 65 insertions(+), 133 deletions(-) diff --git a/manifest.toml b/manifest.toml index 979ee25..1de2e64 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,8 @@ admindoc = "https://www.openproject.org/docs/" code = "https://github.com/opf/openproject" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false ldap = false 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 c4104ea..0bbc2ba 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,25 +1,16 @@ #!/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 NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -27,17 +18,17 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/openproject/" +ynh_backup "/etc/openproject/" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." +ynh_print_info "Backing up the PostgreSQL database..." -ynh_psql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db > db.sql #================================================= # 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 8cb353c..a216e79 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,42 +1,32 @@ #!/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 -#================================================= -# 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" +ynh_systemctl --service=$app --action="start" --log_path="systemd" #================================================= # 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 9798e84..2716a7f 100755 --- 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,22 +9,22 @@ source /usr/share/yunohost/helpers # Installer variables _homedir="/var/$app/" -ynh_app_setting_set --app=$app --key=_homedir --value=$_homedir +ynh_app_setting_set --key=_homedir --value=$_homedir #================================================= # 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 #================================================= # SPECIFIC SETUP #================================================= # OPENPROJECT CONFIGURATION #================================================= -ynh_script_progression --message="Configuring OpenProject..." +ynh_script_progression "Configuring OpenProject..." mkdir -p "/etc/openproject/" _openproject_install_dat="/etc/openproject/installer.dat" @@ -58,38 +52,36 @@ server/hostname $domain server/ssl no EOF -ynh_store_file_checksum --file="$_openproject_install_dat" +ynh_store_file_checksum "$_openproject_install_dat" chmod 750 "/etc/openproject/" chmod -R o-rwx "/etc/openproject/" chown -R $app:$app "/etc/openproject/" -ynh_exec_warn_less openproject config:set PORT=$port -ynh_exec_warn_less openproject config:set SERVER_PROTOCOL_FORCE_HTTPS="true" -ynh_exec_warn_less openproject config:set SERVER_HOSTNAME=$domain -ynh_exec_warn_less openproject config:set SERVER_PATH_PREFIX=$path +ynh_hide_warnings openproject config:set PORT=$port +ynh_hide_warnings openproject config:set SERVER_PROTOCOL_FORCE_HTTPS="true" +ynh_hide_warnings openproject config:set SERVER_HOSTNAME=$domain +ynh_hide_warnings openproject config:set SERVER_PATH_PREFIX=$path -ynh_exec_warn_less openproject configure >> "$YNH_STDINFO" +ynh_hide_warnings openproject configure >> "$YNH_STDINFO" -#================================================= -# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Web-based project management software" --log="systemd" #================================================= # 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" +ynh_systemctl --service=$app --action="start" --log_path="systemd" #================================================= # 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 9852dd5..026bdeb 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,42 +10,42 @@ 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 #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." +ynh_script_progression "Stopping and removing the systemd service..." # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression "Removing NGINX web server configuration..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression "Removing various files..." -ynh_secure_remove --file="$_homedir" +ynh_safe_rm "$_homedir" # Remove a directory securely -ynh_secure_remove --file="/etc/openproject" +ynh_safe_rm "/etc/openproject" #================================================= # 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 50748bc..15c374e 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 @@ -15,60 +9,58 @@ source /usr/share/yunohost/helpers #================================================= # 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" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_db_shell < "./db.sql"" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression "Restoring various files..." -ynh_restore_file --origin_path="/etc/openproject/" +ynh_restore "/etc/openproject/" chmod 750 "/etc/openproject/" chmod -R o-rwx "/etc/openproject/" chown -R $app:$app "/etc/openproject/" -ynh_exec_warn_less openproject config:set PORT=$port -ynh_exec_warn_less openproject config:set SERVER_PROTOCOL_FORCE_HTTPS="true" -ynh_exec_warn_less openproject config:set SERVER_HOSTNAME=$domain -ynh_exec_warn_less openproject config:set SERVER_PATH_PREFIX=$path +ynh_hide_warnings openproject config:set PORT=$port +ynh_hide_warnings openproject config:set SERVER_PROTOCOL_FORCE_HTTPS="true" +ynh_hide_warnings openproject config:set SERVER_HOSTNAME=$domain +ynh_hide_warnings openproject config:set SERVER_PATH_PREFIX=$path -ynh_exec_warn_less openproject configure >> "$YNH_STDINFO" +ynh_hide_warnings openproject configure >> "$YNH_STDINFO" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Web-based project management software" --log=systemd #================================================= # 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" +ynh_systemctl --service=$app --action="start" --log_path="systemd" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +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" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index d11989f..09673bd 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,55 +1,39 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# 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" #================================================= # 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 -#================================================= -# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Web-based project management software" --log=systemd #================================================= # 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" +ynh_systemctl --service=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"