mirror of
https://github.com/YunoHost-Apps/biboumi_ynh.git
synced 2024-09-03 18:15:58 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
5a33253bcc
commit
8860b227f4
8 changed files with 65 additions and 77 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -18,7 +18,8 @@ admindoc = "https://doc.biboumi.louiz.org"
|
||||||
code = "https://github.com/louiz/biboumi"
|
code = "https://github.com/louiz/biboumi"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = false
|
multi_instance = false
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
_get_metronome_config_dir() {
|
_get_metronome_config_dir() {
|
||||||
|
@ -17,17 +13,9 @@ _get_metronome_config_dir() {
|
||||||
# multi_instance=false, there's only one
|
# multi_instance=false, there's only one
|
||||||
metronome_app=$(yunohost app list --json | jq -r '.apps[] | select(.id == "metronome") | .id')
|
metronome_app=$(yunohost app list --json | jq -r '.apps[] | select(.id == "metronome") | .id')
|
||||||
if [[ -z "${metronome_app:-}" ]]; then
|
if [[ -z "${metronome_app:-}" ]]; then
|
||||||
ynh_print_warn --message="Could not find any metronome app!"
|
ynh_print_warn "Could not find any metronome app!"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$(ynh_app_setting_get --app="$metronome_app" --key="install_dir")/conf/conf.d"
|
echo "$(ynh_app_setting_get --app="$metronome_app" --key="install_dir")/conf/conf.d"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
|
@ -8,31 +8,28 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP VARIOUS FILES
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/$app"
|
ynh_backup "/etc/$app"
|
||||||
|
|
||||||
ynh_backup --src_path="/var/lib/$app"
|
ynh_backup "/var/lib/$app"
|
||||||
|
|
||||||
ynh_backup --src_path="$(_get_metronome_config_dir)/$app.cfg.lua"
|
ynh_backup "$(_get_metronome_config_dir)/$app.cfg.lua"
|
||||||
|
|
||||||
ynh_backup --src_path="/var/log/$app/"
|
ynh_backup "/var/log/$app/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# 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)."
|
||||||
|
|
|
@ -19,16 +19,16 @@ fi
|
||||||
# INITIALIZE AND STORE SETTINGS
|
# INITIALIZE AND STORE SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
shared_secret="$(ynh_string_random 25)"
|
shared_secret="$(ynh_string_random --length=25)"
|
||||||
ynh_app_setting_set --app="$app" --key="shared_secret" --value="$shared_secret"
|
ynh_app_setting_set --key="shared_secret" --value="$shared_secret"
|
||||||
|
|
||||||
admin_jid="${admin}@${app}.${domain}"
|
admin_jid="${admin}@${app}.${domain}"
|
||||||
ynh_app_setting_set --app="$app" --key="admin_jid" --value="$admin_jid"
|
ynh_app_setting_set --key="admin_jid" --value="$admin_jid"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DATA DIRECTORY
|
# CREATE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up the data directory..."
|
ynh_script_progression "Setting up the data directory..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R _biboumi:_biboumi "/var/lib/$app"
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
|
@ -36,45 +36,45 @@ chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# APP INITIAL CONFIGURATION
|
# APP INITIAL CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
ynh_script_progression "Adding $app's configuration files..."
|
||||||
|
|
||||||
# Stop the service started by apt install
|
# Stop the service started by apt install
|
||||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
ynh_systemctl --service="$app" --action="stop" --log_path="systemd"
|
||||||
|
|
||||||
# Add metronome component
|
# Add metronome component
|
||||||
metronome_config_dir=$(_get_metronome_config_dir)
|
metronome_config_dir=$(_get_metronome_config_dir)
|
||||||
ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
|
ynh_config_add --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
|
||||||
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
||||||
ynh_systemd_action --service_name="metronome" --action="restart"
|
ynh_systemctl --service="metronome" --action="restart"
|
||||||
|
|
||||||
# Add biboumi configuration
|
# Add biboumi configuration
|
||||||
mkdir -p "/etc/$app/"
|
mkdir -p "/etc/$app/"
|
||||||
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
ynh_config_add --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
||||||
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
systemctl enable "$app.service" --quiet
|
systemctl enable "$app.service" --quiet
|
||||||
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Use logrotate to manage application logfile(s)
|
# Use logrotate to manage application logfile(s)
|
||||||
ynh_use_logrotate
|
ynh_config_add_logrotate
|
||||||
chown -R _biboumi:_biboumi "/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 _biboumi:_biboumi "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed"
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -10,37 +10,37 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
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`)
|
# 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; then
|
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
|
||||||
yunohost service remove "$app"
|
yunohost service remove "$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
|
ynh_systemctl --service="$app" --action="stop" --log_path="systemd"
|
||||||
systemctl disable "$app.service" --quiet
|
systemctl disable "$app.service" --quiet
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_config_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE VARIOUS FILES
|
# REMOVE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing various files..."
|
ynh_script_progression "Removing various files..."
|
||||||
|
|
||||||
# Remove data directory
|
# Remove data directory
|
||||||
ynh_secure_remove --file="/var/lib/$app"
|
ynh_safe_rm "/var/lib/$app"
|
||||||
|
|
||||||
# Remove a directory securely
|
# Remove a directory securely
|
||||||
ynh_secure_remove --file="/etc/$app"
|
ynh_safe_rm "/etc/$app"
|
||||||
|
|
||||||
# Remove Metronome component
|
# Remove Metronome component
|
||||||
ynh_secure_remove --file="$(_get_metronome_config_dir)/$app.cfg.lua"
|
ynh_safe_rm "$(_get_metronome_config_dir)/$app.cfg.lua"
|
||||||
ynh_systemd_action --action=restart --service_name=metronome
|
ynh_systemctl --action=restart --service=metronome
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed"
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -11,7 +11,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
ynh_script_progression "Validating restoration parameters..."
|
||||||
|
|
||||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then
|
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then
|
||||||
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
|
||||||
|
@ -20,46 +20,46 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# 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="/var/lib/$app"
|
ynh_restore "/var/lib/$app"
|
||||||
chown -R _biboumi:_biboumi "/var/lib/$app"
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring various files..."
|
ynh_script_progression "Restoring various files..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/$app"
|
ynh_restore "/etc/$app"
|
||||||
chown -R _biboumi:_biboumi "/etc/$app"
|
chown -R _biboumi:_biboumi "/etc/$app"
|
||||||
|
|
||||||
metronome_config_dir=$(_get_metronome_config_dir)
|
metronome_config_dir=$(_get_metronome_config_dir)
|
||||||
ynh_restore_file --origin_path="$metronome_config_dir/$app.cfg.lua"
|
ynh_restore "$metronome_config_dir/$app.cfg.lua"
|
||||||
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
||||||
ynh_systemd_action --service_name=metronome --action="restart"
|
ynh_systemctl --service=metronome --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
ynh_script_progression "Restoring system configurations related to $app..."
|
||||||
|
|
||||||
systemctl enable "$app.service" --quiet
|
systemctl enable "$app.service" --quiet
|
||||||
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
ynh_restore "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/var/log/$app/"
|
ynh_restore "/var/log/$app/"
|
||||||
chown -R _biboumi:_biboumi "/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 _biboumi:_biboumi "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
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" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app"
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -10,14 +10,14 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DIRECTORIES
|
# CREATE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up the data directory..."
|
ynh_script_progression "Setting up the data directory..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R _biboumi:_biboumi "/var/lib/$app"
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
|
@ -25,40 +25,40 @@ chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
|
ynh_script_progression "Updating $app's configuration files..."
|
||||||
|
|
||||||
# Upgrade metronome component
|
# Upgrade metronome component
|
||||||
metronome_config_dir=$(_get_metronome_config_dir)
|
metronome_config_dir=$(_get_metronome_config_dir)
|
||||||
ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
|
ynh_config_add --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
|
||||||
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
|
||||||
ynh_systemd_action --service_name=metronome --action="restart"
|
ynh_systemctl --service=metronome --action="restart"
|
||||||
|
|
||||||
# Upgrade biboumi configuration
|
# Upgrade biboumi configuration
|
||||||
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
ynh_config_add --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
||||||
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
systemctl enable "$app.service" --quiet
|
systemctl enable "$app.service" --quiet
|
||||||
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_config_add_logrotate
|
||||||
chown -R _biboumi:_biboumi "/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 _biboumi:_biboumi "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app" --action="start" --wait_until="Authenticated with the XMPP server"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed"
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue