1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/influxdb_v2_ynh.git synced 2024-09-03 19:26:11 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-30 23:36:43 +02:00 committed by Alexandre Aubin
parent 3c131354c4
commit c3d12bfcb9
11 changed files with 102 additions and 167 deletions

1
.gitignore vendored
View file

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

View file

@ -16,7 +16,8 @@ admindoc = "https://docs.influxdata.com/influxdb/v2.0/"
cpe = "cpe:2.3:a:influxdata:influxdb"
[integration]
yunohost = ">= 11.1.21"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = ["amd64", "arm64"]
multi_instance = false
ldap = false

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,36 +1,27 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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"
#=================================================
# SPECIFIC BACKUP
@ -38,17 +29,17 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP LOGROTATE AND LOGS
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/var/log/$app"
ynh_backup "/etc/logrotate.d/$app"
ynh_backup "/var/log/$app"
#=================================================
# 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

@ -1,41 +1,31 @@
#!/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..." --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"
#=================================================
# 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
#=================================================
# GENERIC FINALISATION
#=================================================
# 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="Change of URL completed for $app" --last
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -17,37 +11,36 @@ influxdb_admin_token=$(ynh_string_random --length=64 --filter='A-Za-z0-9-_')
# Check if the retention value is valid
if ! echo "$influxdb_bucket_retention" | grep -qE '^(0|[0-9]+(ns|u|µ|ms|s|m|h|d|w))$'; then
ynh_die --message="Invalid retention value. It should be either 0 (infinite) or a number followed by a duration unit (ns, u, µ, ms, s, m, h, d, w)."
ynh_die "Invalid retention value. It should be either 0 (infinite) or a number followed by a duration unit (ns, u, µ, ms, s, m, h, d, w)."
fi
ynh_app_setting_set --app=$app --key=influxdb_org_name --value=$influxdb_org_name
ynh_app_setting_set --app=$app --key=influxdb_bucket_name --value=$influxdb_bucket_name
ynh_app_setting_set --app=$app --key=influxdb_bucket_retention --value=$influxdb_bucket_retention
ynh_app_setting_set --app=$app --key=influxdb_admin_token --value=$influxdb_admin_token
ynh_app_setting_set --key=influxdb_org_name --value=$influxdb_org_name
ynh_app_setting_set --key=influxdb_bucket_name --value=$influxdb_bucket_name
ynh_app_setting_set --key=influxdb_bucket_retention --value=$influxdb_bucket_retention
ynh_app_setting_set --key=influxdb_admin_token --value=$influxdb_admin_token
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir" --source_id=influxdb2
ynh_setup_source --dest_dir="$install_dir" --source_id=influx
chmod -R 750 "$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 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 | chown -R $app:$app "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# CONFIGURE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Setting permissions for the data directory..." --weight=1
ynh_script_progression "Setting permissions for the data directory..."
chmod -R 0750 "$data_dir"
chown -R $app:$app "$data_dir"
@ -55,52 +48,52 @@ chown -R $app:$app "$data_dir"
#=================================================
# ADD CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="config.toml.example" --destination="$install_dir/config.toml"
ynh_config_add --template="config.toml.example" --destination="$install_dir/config.toml"
chmod 400 "$install_dir/config.toml"
chown $app:$app "$install_dir/config.toml"
#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.toml"
#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.toml"
#=================================================
# CONFIGURE 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 --service="$app" --template="systemd.service"
ynh_config_add_systemd
#=================================================
# 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" --log="/var/log/$app/$app.log"
#=================================================
# START AND ENABLE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="enable"
ynh_systemd_action --service_name=$app --action="start"
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service=$app --action="enable"
ynh_systemctl --service=$app --action="start"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_use_logrotate
ynh_script_progression "Configuring log rotation..."
ynh_config_add_logrotate
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring $app ..." --weight=30
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="msg=Listening"
ynh_script_progression "Configuring $app ..."
ynh_systemctl --service=$app --action="start" --wait_until="msg=Listening"
# First setup InfluxDB v2 using influx
ynh_exec_as $app $install_dir/influx setup --force --skip-verify --name default --configs-path $install_dir/.influxdbv2/configs --host http://localhost:$port --bucket $influxdb_bucket_name --org $influxdb_org_name --username $admin --password "$password" --retention $influxdb_bucket_retention --token $influxdb_admin_token
ynh_exec_as_app $install_dir/influx setup --force --skip-verify --name default --configs-path $install_dir/.influxdbv2/configs --host http://localhost:$port --bucket $influxdb_bucket_name --org $influxdb_org_name --username $admin --password "$password" --retention $influxdb_bucket_retention --token $influxdb_admin_token
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression "Installation of $app completed"

View file

@ -1,58 +1,52 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# REMOVE SYSTEMD SERVICE
if ynh_exec_warn_less yunohost service status $app >/dev/null
#=================================================
ynh_script_progression "Removing system configurations related to $app..."
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
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
ynh_remove_systemd_config
ynh_script_progression "Stopping and removing the systemd service..."
ynh_config_remove_systemd
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
ynh_remove_logrotate
ynh_script_progression "Removing logrotate configuration..."
ynh_config_remove_logrotate
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_remove_nginx_config
ynh_script_progression "Removing NGINX web server configuration..."
ynh_config_remove_nginx
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing InfluxDB V2 data" --weight=1
ynh_script_progression "Removing InfluxDB V2 data"
ynh_secure_remove --file="/var/log/$app"
ynh_secure_remove --file="$data_dir"
#REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
ynh_safe_rm "$data_dir"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression "Removal of $app completed"

View file

@ -1,30 +1,23 @@
#!/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..." --weight=1
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R 750 "$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 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 | chown -R $app:$app "$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"
chmod -R 0750 "$data_dir"
chown -R $app:$app "$data_dir"
@ -32,37 +25,35 @@ chown -R $app:$app "$data_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_file --origin_path="/etc/systemd/system/$app.service"
ynh_systemd_action --service_name=$app --action="enable"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/systemd/system/$app.service"
ynh_systemctl --service=$app --action="enable"
yunohost service add "$app" --log="/var/log/$app/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION AND LOGS
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_script_progression "Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/var/log/$app"
chown -R $app:$app "/var/log/$app"
ynh_restore "/var/log/$app"
#REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# START APP AND RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=$app --action="start"
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"

View file

@ -1,25 +1,15 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service=$app --action="stop"
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
@ -27,65 +17,65 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
# 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=1
ynh_script_progression "Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir" --source_id=influxdb2 --keep=".influxdbv2/"
ynh_setup_source --dest_dir="$install_dir" --source_id=influx
fi
chmod -R 750 "$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 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 | chown -R $app:$app "$install_dir"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# ADD CONFIGURATION
#=================================================
ynh_script_progression --message="Adding $app configuration file..." --weight=1
ynh_script_progression "Adding $app configuration file..."
ynh_add_config --template="config.toml.example" --destination="$install_dir/config.toml"
ynh_config_add --template="config.toml.example" --destination="$install_dir/config.toml"
chmod 400 "$install_dir/config.toml"
chown $app:$app "$install_dir/config.toml"
#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.toml"
#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.toml"
#=================================================
# CONFIGURE SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config --service="$app" --template="systemd.service"
ynh_script_progression "Configuring $app's systemd service..."
ynh_config_add_systemd
#=================================================
# 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" --log="/var/log/$app/$app.log"
#=================================================
# START AND ENABLE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="enable"
ynh_systemd_action --service_name=$app --action="start"
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service=$app --action="enable"
ynh_systemctl --service=$app --action="start"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_use_logrotate
ynh_script_progression "Configuring log rotation..."
ynh_config_add_logrotate
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"

View file

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

View file

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