1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/biboumi_ynh.git synced 2024-09-03 18:15:58 +02:00

Various fixes

This commit is contained in:
yalh76 2021-08-15 21:31:52 +02:00
parent 4e41597eb4
commit dc9cb69cc6
7 changed files with 61 additions and 38 deletions

View file

@ -1,15 +1,15 @@
hostname=biboumi.__DOMAIN__ hostname=__APP__.__DOMAIN__
password=__SECRET__ password=__SHARED_SECRET__
#xmpp_server_ip=127.0.0.1 #xmpp_server_ip=127.0.0.1
#port=5347 #port=5347
db_name=/var/lib/biboumi/biboumi.sqlite db_name=/var/lib/__APP__/__APP__.sqlite
identd_port=__PORT__ identd_port=__PORT__
admin=__ADMIN_JID__ admin=__ADMIN_JID__
realname_customization=true realname_customization=true
realname_from_jid=false realname_from_jid=false
log_level=1 log_level=1
log_file=/var/log/biboumi/biboumi.log log_file=/var/log/__APP__/__APP__.log
#ca_file= #ca_file=
#outgoing_bind= #outgoing_bind=

View file

@ -1,2 +1,2 @@
Component "biboumi.__DOMAIN__" Component "__APP__.__DOMAIN__"
component_secret = "__SHARED_SECRET__" component_secret = "__SHARED_SECRET__"

View file

@ -41,12 +41,11 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/biboumi" ynh_backup --src_path="/etc/$app"
ynh_backup --src_path="/var/lib/biboumi" ynh_backup --src_path="/var/lib/$app"
ynh_backup --src_path="/etc/metronome/conf.d/$app.cfg.lua"
ynh_backup --src_path="/etc/metronome/conf.d/biboumi.cfg.lua"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -70,29 +70,33 @@ ynh_script_progression --message="Adding a configuration file..."
# Create a secret password that will be shared by metronome and biboumi. # Create a secret password that will be shared by metronome and biboumi.
shared_secret="$(ynh_string_random 25)" shared_secret="$(ynh_string_random 25)"
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
# Biboumi needs at least one admin JID. # Biboumi needs at least one admin JID.
admin_jid="${admin}@biboumi.${domain}" admin_jid="${admin}@$app.${domain}"
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
ynh_add_config --template="../conf/biboumi/biboumi.cfg" --destination="/etc/biboumi/biboumi.cfg" ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown _biboumi /etc/biboumi chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#================================================= #=================================================
# CONFIGURE METRONOME # CONFIGURE METRONOME
#================================================= #=================================================
# Add metronome component # Add metronome component
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/biboumi.cfg.lua" ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
#================================================= #=================================================
# CREATE DIRECTORIES # CREATE DIRECTORIES
#================================================= #=================================================
mkdir -p /var/lib/biboumi mkdir -p /var/lib/$app
# Set permissions to app files # Set permissions to app files
chown _biboumi /var/lib/biboumi chown -R _biboumi:_biboumi "/var/lib/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -101,17 +105,17 @@ chown _biboumi /var/lib/biboumi
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 ynh_script_progression --message="Configuring log rotation..." --weight=1
mkdir -p /var/log/biboumi mkdir -p /var/log/$app
chown _biboumi /var/log/biboumi chown -R _biboumi:_biboumi "/var/log/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate /var/log/biboumi/ ynh_use_logrotate /var/log/$app/
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -119,7 +123,7 @@ yunohost service add $app --description="XMPP gateway for the IRC network" --log
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --action=restart --service_name=metronome ynh_systemd_action --action=restart --service_name=metronome
ynh_systemd_action --action=restart --service_name=biboumi ynh_systemd_action --action=restart --service_name=$app
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT

View file

@ -52,9 +52,10 @@ ynh_remove_logrotate
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/var/lib/$app"
# Remove a directory securely # Remove a directory securely
ynh_secure_remove --file="/etc/$app" ynh_secure_remove --file="/etc/$app"
ynh_secure_remove --file="/var/lib/$app"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
@ -63,10 +64,11 @@ ynh_secure_remove --file="/var/log/$app"
# REMOVE METRONOME COMPONENT # REMOVE METRONOME COMPONENT
#================================================= #=================================================
ynh_secure_remove "/etc/metronome/conf.d/biboumi.cfg.lua" ynh_secure_remove --file="/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --action=restart --service_name=metronome
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of Biboumi completed" --last ynh_script_progression --message="Removal of $app completed"

View file

@ -51,17 +51,21 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." ynh_script_progression --message="Restoring various files..."
ynh_restore_file--origin_path= "/etc/biboumi" ynh_restore_file--origin_path= "/etc/$app"
ynh_restore_file --origin_path="/var/lib/biboumi" chown -R _biboumi:_biboumi /etc/$app
ynh_restore_file --origin_path="/etc/metronome/conf.d/biboumi.cfg.lua"
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi ynh_restore_file --origin_path="/var/lib/$app"
chown -R _biboumi:_biboumi /var/lib/$app
ynh_restore_file --origin_path="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -69,15 +73,16 @@ yunohost service add $app --description="XMPP gateway for the IRC network" --log
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --action=restart --service_name=metronome ynh_systemd_action --action=restart --service_name=metronome
ynh_systemd_action --action=restart --service_name=biboumi ynh_systemd_action --action=restart --service_name=$app
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/biboumi mkdir -p /var/log/$app
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
chown -R _biboumi:_biboumi /var/log/$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -19,6 +19,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
shared_secret=$(ynh_app_setting_get --app=$app --key=shared_secret)
admin_jid=$(ynh_app_setting_get --app=$app --key=admin_jid)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -30,6 +32,7 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -50,6 +53,16 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Prevent conflict with other apps on the same domain # Prevent conflict with other apps on the same domain
ynh_app_setting_set --app=$app --key=no_sso --value=1 ynh_app_setting_set --app=$app --key=no_sso --value=1
if [ -z "$shared_secret" ]; then
shared_secret="$(grep password "/etc/biboumi/biboumi.cfg" | cut -d= -f2)"
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
fi
if [ -z "$admin_jid" ]; then
admin_jid="${admin}@$app.${domain}"
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
fi
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -64,25 +77,25 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="/etc/biboumi/biboumi.cfg" --destination="/etc/biboumi/biboumi.cfg" ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown _biboumi /etc/biboumi chown _biboumi /etc/$app
#================================================= #=================================================
# UPGRADE METRONOME COMPONENT # UPGRADE METRONOME COMPONENT
#================================================= #=================================================
# Upgrade metronome component # Upgrade metronome component
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/biboumi.cfg.lua" ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
#================================================= #=================================================
# CREATE DIRECTORIES # CREATE DIRECTORIES
#================================================= #=================================================
mkdir -p /var/lib/biboumi mkdir -p /var/lib/$app
# Set permissions to app files # Set permissions to app files
chown _biboumi /var/lib/biboumi chown _biboumi /var/lib/$app
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -91,7 +104,7 @@ chown _biboumi /var/lib/biboumi
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
chown _biboumi /var/log/biboumi chown _biboumi /var/log/$app
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
@ -100,7 +113,7 @@ ynh_use_logrotate --non-append
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log" yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -108,7 +121,7 @@ yunohost service add $app --description="XMPP gateway for the IRC network" --log
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --action=restart --service_name=metronome ynh_systemd_action --action=restart --service_name=metronome
ynh_systemd_action --action=restart --service_name=biboumi ynh_systemd_action --action=restart --service_name=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT