[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 22:51:12 +02:00 committed by Alexandre Aubin
parent d0aafaf9e7
commit f0c06dde84
9 changed files with 76 additions and 137 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -19,7 +19,8 @@ admindoc = "https://www.elastic.co/guide/en/elasticsearch/reference/7.17/elastic
code = "https://github.com/elastic/elasticsearch"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64"]
multi_instance = true

View file

@ -1,17 +1,5 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

View file

@ -1,31 +1,22 @@
#!/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"
#=================================================
# SPECIFIC BACKUP
@ -33,22 +24,22 @@ ynh_backup --src_path="$data_dir" --is_big
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_backup "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# 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)."

View file

@ -8,15 +8,9 @@
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
@ -29,11 +23,11 @@ final_path=$(ynh_app_setting_get $app final_path)
#=================================================
get__xms() {
ynh_app_setting_get --app=$app --key=xms
ynh_app_setting_get --key=xms
}
get__xmx() {
ynh_app_setting_get --app=$app --key=xmx
ynh_app_setting_get --key=xmx
}
#=================================================
@ -45,22 +39,20 @@ get__xmx() {
#=================================================
regenerate_jvm_options() {
ynh_add_config --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options"
ynh_config_add --template="jvm.options" --destination="$final_path/config/jvm.options.d/yunohost.options"
chown $app:$app "$final_path/config/jvm.options.d/yunohost.options"
chmod 400 "$final_path/config/jvm.options.d/yunohost.options"
}
set__xms() {
ynh_app_setting_set --app=$app --key=xms --value=$xms
ynh_app_setting_set --key=xms --value=$xms
regenerate_jvm_options
}
set__xmx() {
ynh_app_setting_set --app=$app --key=xmx --value=$xmx
ynh_app_setting_set --key=xmx --value=$xmx
regenerate_jvm_options
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,35 +10,34 @@ source /usr/share/yunohost/helpers
xms=256m
xmx=1g
ynh_app_setting_set --app=$app --key=xms --value=$xms
ynh_app_setting_set --app=$app --key=xmx --value=$xmx
ynh_app_setting_set --key=xms --value=$xms
ynh_app_setting_set --key=xmx --value=$xmx
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=15
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"
ynh_setup_source --dest_dir="$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"
#=================================================
# ADD CONFIGURATIONS
#=================================================
ynh_script_progression --message="Adding the configuration files..." --weight=1
ynh_script_progression "Adding the configuration files..."
ynh_add_config --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_add_config --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"
ynh_config_add --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_config_add --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"
chmod 400 "$install_dir/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
chown $app:$app "$install_dir/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#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/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#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/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#=================================================
# INCREASE MAX_MAP_COUNT
#=================================================
ynh_script_progression --message="Increasing maximum map count (sysctl)..."
ynh_script_progression "Increasing maximum map count (sysctl)..."
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-max_map_count-elasticsearch.conf /etc/sysctl.d/
@ -57,26 +50,26 @@ fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
ynh_config_add_logrotate
yunohost service add $app --description="Distributed and RESTful search engine" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,20 +10,20 @@ 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..." --weight=1
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 the app-specific logrotate config
ynh_remove_logrotate
ynh_config_remove_logrotate
if [ -e "/etc/sysctl.d/90-max_map_count-elasticsearch.conf" ]; then
ynh_secure_remove --file="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_safe_rm "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
# Reload the kernel configuration.
if ! [ "${container:-}" = "lxc" ] # lxc doesn't allow sysctl to play with kernel options.
then
@ -41,4 +35,4 @@ fi
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -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,19 +7,18 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
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 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"
chown -R $app:www-data "$data_dir"
@ -34,9 +27,9 @@ chown -R $app:www-data "$data_dir"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_script_progression "Restoring various files..."
ynh_restore_file --origin_path="/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
ynh_restore "/etc/sysctl.d/90-max_map_count-elasticsearch.conf"
if ! [ "${container:-}" = "lxc" ] # lxc doesn't allow sysctl to play with kernel options.
then
sysctl -p /etc/sysctl.d/90-max_map_count-elasticsearch.conf
@ -45,24 +38,24 @@ fi
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_script_progression "Restoring $app's systemd service..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
yunohost service add $app --description="Distributed and RESTful search engine" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression "Restoration completed for $app"

View file

@ -1,66 +1,52 @@
#!/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..." --weight=1
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="stop"
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression "Ensuring downward compatibility..."
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
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 source files..." --weight=20
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
# The keep option prevents this warning:
# "File .... has been manually modified since the installation or last upgrade."
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/elasticsearch.yml"
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="config/elasticsearch.yml"
fi
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"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_script_progression "Updating configuration..."
ynh_add_config --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_add_config --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"
ynh_config_add --template="elasticsearch.yml" --destination="$install_dir/config/elasticsearch.yml"
ynh_config_add --template="jvm.options" --destination="$install_dir/config/jvm.options.d/yunohost.options"
chmod 400 "$install_dir/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
chown $app:$app "$install_dir/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#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/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#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/config/elasticsearch.yml" "$install_dir/config/jvm.options.d/yunohost.options"
#=================================================
# INCREASE MAX_MAP_COUNT
#=================================================
ynh_script_progression --message="Increasing maximum map count (sysctl)..."
ynh_script_progression "Increasing maximum map count (sysctl)..."
# Increase the maximum number of files inotify can monitor.
cp -a ../conf/90-max_map_count-elasticsearch.conf /etc/sysctl.d/
@ -73,25 +59,25 @@ fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_script_progression "Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_config_add_systemd
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
ynh_config_add_logrotate
yunohost service add $app --description="Distributed and RESTful search engine" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"