From 88ab297d311b92c941edb6bcc6f9a7d2766b03c7 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Fri, 30 Aug 2024 22:46:01 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 14 +------------ scripts/backup | 25 ++++++++--------------- scripts/change_url | 14 +++---------- scripts/install | 42 +++++++++++++++----------------------- scripts/remove | 20 +++++++----------- scripts/restore | 51 +++++++++++++++++++--------------------------- scripts/upgrade | 46 ++++++++++++++++------------------------- 8 files changed, 75 insertions(+), 140 deletions(-) diff --git a/manifest.toml b/manifest.toml index 15b2078..e17c234 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ code = "https://github.com/apache/couchdb" cpe = "cpe:2.3:a:apache:couchdb" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = 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 907da7a..691309d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,44 +1,35 @@ #!/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 DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_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" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +ynh_backup "/etc/fail2ban/jail.d/$app.conf" +ynh_backup "/etc/fail2ban/filter.d/$app.conf" #================================================= # SPECIFIC BACKUP @@ -46,10 +37,10 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" # BACKUP LOGROTATE #================================================= -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" #================================================= # 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 16e0f3c..39d37fc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,25 +1,17 @@ #!/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=2 +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 9db34d9..e6451cd 100755 --- a/scripts/install +++ b/scripts/install @@ -1,36 +1,29 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers - #================================================= # INITIALIZE AND STORE SETTINGS #================================================= # Not stored by default -ynh_app_setting_set --app=$app --key=password --value="$password" +ynh_app_setting_set --key=password --value="$password" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=3 +ynh_script_progression "Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # SPECIFIC SETUP #================================================= # INSTALL COUCHDB #================================================= -ynh_script_progression --message="Installing CouchDB..." --weight=60 +ynh_script_progression "Installing CouchDB..." echo "\ couchdb couchdb/mode select standalone @@ -44,7 +37,7 @@ couchdb couchdb/adminpass_again password $password couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb -ynh_install_extra_app_dependencies \ +ynh_apt_install_dependencies_from_extra_repository \ --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ --key="https://couchdb.apache.org/repo/keys.asc" \ --package="couchdb" @@ -52,42 +45,39 @@ ynh_install_extra_app_dependencies \ #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=2 +ynh_script_progression "Adding $app's configuration..." # Customize a bit the couch config -ynh_add_config --template="../conf/couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" +ynh_config_add --template="couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" - -#================================================= -# GENERIC FINALIZATION +#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:$app" "$install_dir" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=2 +ynh_script_progression "Configuring log rotation..." # Use logrotate to manage application logfile(s) -ynh_use_logrotate +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Configuring Fail2Ban..." --weight=3 +ynh_script_progression "Configuring Fail2Ban..." # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " --max_retry=5 +ynh_config_add_fail2ban --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " #================================================= # 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 469ef62..96194aa 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 @@ -14,26 +8,26 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=5 +ynh_script_progression "Removing system configurations related to $app..." # 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..." --weight=2 + ynh_script_progression "Removing $app service integration..." yunohost service remove $app fi # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove the dedicated Fail2Ban config -ynh_remove_fail2ban_config +ynh_config_remove_fail2ban #================================================= # 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 82e7cca..b7f47a3 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,41 +9,41 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=10 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" mkdir -p $data_dir #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2 +ynh_script_progression "Restoring the Fail2Ban configuration..." -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_restore "/etc/fail2ban/jail.d/$app.conf" +ynh_restore "/etc/fail2ban/filter.d/$app.conf" +ynh_systemctl --action=restart --service=fail2ban #================================================= # SPECIFIC RESTORATION #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +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" #================================================= # REINSTALL COUCHDB #================================================= -ynh_script_progression --message="Reinstalling couchdb..." --weight=40 +ynh_script_progression "Reinstalling couchdb..." echo "\ couchdb couchdb/mode select standalone @@ -63,15 +57,14 @@ couchdb couchdb/adminpass_again password $password couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb -ynh_install_extra_app_dependencies \ +ynh_apt_install_dependencies_from_extra_repository \ --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ --key="https://couchdb.apache.org/repo/keys.asc" \ --package="couchdb" -chmod 750 "$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 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:$app "$install_dir" chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" chown -R $app:www-data "$data_dir" @@ -79,28 +72,26 @@ chown -R $app:www-data "$data_dir" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression "Restoring the logrotate configuration..." -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" -#================================================= -# 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 4ef7419..adfb7ea 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,33 +1,24 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +ynh_script_progression "Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx -#================================================= -# SPECIFIC UPGRADE #================================================= # UPGRADING COUCHDB #================================================= -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 CouchDB..." --weight=50 + ynh_script_progression "Upgrading CouchDB..." echo "\ couchdb couchdb/mode select standalone @@ -41,7 +32,7 @@ then couchdb couchdb/adminpass_again seen true" | debconf-set-selections DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb - ynh_install_extra_app_dependencies \ + ynh_apt_install_dependencies_from_extra_repository \ --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \ --key="https://couchdb.apache.org/repo/keys.asc" \ --package="couchdb" @@ -50,41 +41,38 @@ fi #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression "Updating configuration..." -ynh_add_config --template="../conf/couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" +ynh_config_add --template="couch_ynh.ini" --destination="$install_dir/etc/local.d/couch_ynh.ini" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" - -#================================================= -# GENERIC FINALIZATION +#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:$app" "$install_dir" #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression "Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_config_add_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 +ynh_script_progression "Integrating service in YunoHost..." yunohost service add $app --description="Open-source document-oriented NoSQL database" --log="/var/log/$app/$app.log" --needs_exposed_ports "$port" #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=3 +ynh_script_progression "Reconfiguring Fail2Ban..." # Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " --max_retry=5 +ynh_config_add_fail2ban --logpath="/var/log/couchdb/couchdb.log" --failregex="[warning] .*couch_httpd_auth: Authentication failed for user .+ from " #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"