mirror of
https://github.com/YunoHost-Apps/biboumi_ynh.git
synced 2024-09-03 18:15:58 +02:00
Apply last example_ynh (#14)
* Apply last example_ynh * Fix $biboumi_config_file * Update LICENSE * fix install * Various fixes * Cleanup * Fix variables not initialized * fix variable... again * Fix install
This commit is contained in:
parent
8eefa0a5ae
commit
8a619ba379
10 changed files with 190 additions and 175 deletions
9
LICENSE
9
LICENSE
|
@ -1,4 +1,7 @@
|
||||||
File containing the license of your package.
|
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
||||||
More information here:
|
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||||
https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13---indiquer-la-licence-associ%C3%A9e-au-paquet---brouillon--auto--working-
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
setup_private=0
|
setup_private=0
|
||||||
setup_public=0
|
setup_public=0
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
# 8.3~ynh1
|
||||||
|
upgrade=1 from_commit=6596c7e12e17a2b9149b20739e916184e71fdfbd
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
port_already_use=1 (113)
|
port_already_use=1 (113)
|
||||||
|
@ -17,3 +19,6 @@
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=pitchum@gramaton.org
|
Email=pitchum@gramaton.org
|
||||||
Notification=none
|
Notification=none
|
||||||
|
;;; Upgrade options
|
||||||
|
; commit=6596c7e12e17a2b9149b20739e916184e71fdfbd
|
||||||
|
name=8.3~ynh1.
|
||||||
|
|
|
@ -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=
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Component "biboumi.__DOMAIN__"
|
Component "__APP__.__DOMAIN__"
|
||||||
component_secret = "__SECRET__"
|
component_secret = "__SHARED_SECRET__"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# 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 ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -30,27 +31,24 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP THE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_backup "/etc/biboumi"
|
|
||||||
ynh_backup "/var/lib/biboumi"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/logrotate.d/$app"
|
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP METRONOME CONFIG
|
# BACKUP VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/metronome/conf.d/biboumi.cfg.lua"
|
ynh_backup --src_path="/etc/$app"
|
||||||
|
|
||||||
|
ynh_backup --src_path="/var/lib/$app"
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for Biboumi. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -25,9 +25,13 @@ admin=$YNH_APP_ARG_ADMIN
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
shared_secret="$(ynh_string_random 25)"
|
||||||
|
admin_jid="${admin}@$app.${domain}"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating installation parameters..."
|
||||||
|
|
||||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
||||||
then
|
then
|
||||||
|
@ -37,101 +41,103 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Storing installation settings..." --weight=1
|
ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
|
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
|
||||||
|
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Finding an available port..." --weight=2
|
ynh_script_progression --message="Finding an available port..."
|
||||||
|
|
||||||
# Find a free port
|
# Find an available port
|
||||||
port=$(ynh_find_port --port=113)
|
port=$(ynh_find_port --port=113)
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=9
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
|
||||||
# CONFIGURE BIBOUMI
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Create a secret password that will be shared by metronome and biboumi.
|
|
||||||
shared_secret="$(ynh_string_random 25)"
|
|
||||||
|
|
||||||
# Biboumi needs at least one admin JID.
|
|
||||||
admin_jid="${admin}@biboumi.${domain}"
|
|
||||||
|
|
||||||
biboumi_config_file="/etc/biboumi/biboumi.cfg"
|
|
||||||
|
|
||||||
# Create the biboumi config file.
|
|
||||||
cp ../conf/biboumi.cfg "$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="${port}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__ADMIN_JID__" --replace_string="${admin_jid}" --target_file="$biboumi_config_file"
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
|
||||||
ynh_store_file_checksum "$biboumi_config_file"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE METRONOME
|
# CONFIGURE METRONOME
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring Metronome..."
|
||||||
|
|
||||||
# Add metronome component
|
# Add metronome component
|
||||||
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/
|
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
|
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
|
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=metronome --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DIRECTORIES
|
# CREATE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Creating a data directory..."
|
||||||
|
|
||||||
mkdir -p /var/log/biboumi /var/lib/biboumi
|
mkdir -p /var/lib/$app
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD A CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding a configuration file..."
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
||||||
|
|
||||||
|
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
ynh_script_progression --message="Configuring log rotation..."
|
||||||
|
|
||||||
|
mkdir -p /var/log/$app
|
||||||
|
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add biboumi --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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SET THE APP AS NOT USING THE SSO
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
sleep 5
|
||||||
|
ynh_systemd_action --service_name=$app --action="restart"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring permissions..."
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RELOAD SERVICES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_systemd_action --action=restart --service_name=metronome
|
|
||||||
ynh_systemd_action --action=restart --service_name=biboumi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of Biboumi completed" --last
|
ynh_script_progression --message="Installation of $app completed"
|
||||||
|
|
|
@ -12,64 +12,61 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE FROM ADMIN PANEL
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||||
if yunohost service status | grep -q $app
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
ynh_script_progression --message="Removing $app service integration..."
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=4
|
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing Biboumi directory..." --weight=2
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_secure_remove "/etc/biboumi"
|
|
||||||
ynh_secure_remove "/var/lib/biboumi"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGROTATE CONFIGURATION
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
|
ynh_script_progression --message="Removing logrotate configuration..."
|
||||||
|
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..."
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE LOGS
|
# REMOVE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing various files..."
|
||||||
|
|
||||||
ynh_secure_remove "/var/log/biboumi"
|
# Remove data directory
|
||||||
|
ynh_secure_remove --file="/var/lib/$app"
|
||||||
|
|
||||||
#=================================================
|
# Remove a directory securely
|
||||||
# REMOVE METRONOME COMPONENT
|
ynh_secure_remove --file="/etc/$app"
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_secure_remove "/etc/metronome/conf.d/biboumi.cfg.lua"
|
# Remove the log files
|
||||||
|
ynh_secure_remove --file="/var/log/$app"
|
||||||
|
|
||||||
|
# Remove Metronome component
|
||||||
|
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"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# 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 ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
|
||||||
then
|
then
|
||||||
|
@ -40,55 +41,52 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=9
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Make sure that stretch-backports is enabled
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring various files..."
|
||||||
|
|
||||||
ynh_restore_file "/etc/biboumi"
|
ynh_restore_file --origin_path="/etc/$app"
|
||||||
ynh_restore_file "/var/lib/biboumi"
|
chown -R _biboumi:_biboumi /etc/$app
|
||||||
|
|
||||||
#=================================================
|
ynh_restore_file --origin_path="/var/lib/$app"
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
chown -R _biboumi:_biboumi /var/lib/$app
|
||||||
#=================================================
|
|
||||||
|
|
||||||
yunohost service add biboumi --description="XMPP gateway for the IRC network" --log="/var/log/biboumi/biboumi.log"
|
ynh_restore_file --origin_path="/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
|
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
|
ynh_systemd_action --service_name=metronome --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE LOGROTATE CONFIGURATION
|
# RESTORE THE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the logrotate configuration..."
|
||||||
|
|
||||||
mkdir -p /var/log/biboumi
|
mkdir -p /var/log/$app
|
||||||
ynh_restore_file "/etc/logrotate.d/$app"
|
chown -R _biboumi:_biboumi "/var/log/$app"
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
# Restore permissions on app files
|
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
|
||||||
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE METRONOME CONFIG
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
|
||||||
ynh_restore_file "/etc/metronome/conf.d/biboumi.cfg.lua"
|
ynh_systemd_action --service_name=$app --action="restart"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# RELOAD SERVICES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_systemd_action --action=restart --service_name=metronome
|
|
||||||
ynh_systemd_action --action=restart --service_name=biboumi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for Biboumi" --last
|
ynh_script_progression --message="Restoration completed for $app"
|
||||||
|
|
110
scripts/upgrade
110
scripts/upgrade
|
@ -12,31 +12,27 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Checking version..."
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
||||||
|
|
||||||
# Prevent conflict with other apps on the same domain
|
|
||||||
ynh_app_setting_set --app=$app --key=no_sso --value=1
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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
|
||||||
|
@ -49,81 +45,93 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
|
# Prevent conflict with other apps on the same domain
|
||||||
|
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
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=9
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
|
||||||
# CONFIGURE BIBOUMI
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
biboumi_config_file="/etc/biboumi/biboumi.cfg"
|
|
||||||
|
|
||||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
|
||||||
ynh_backup_if_checksum_is_different "$biboumi_config_file"
|
|
||||||
|
|
||||||
# Get shared_secret from the config file
|
|
||||||
shared_secret="$(grep password "$biboumi_config_file" | cut -d= -f2)"
|
|
||||||
|
|
||||||
# Biboumi needs at least one admin JID.
|
|
||||||
admin_jid="${admin}@biboumi.${domain}"
|
|
||||||
|
|
||||||
# Create the biboumi config file.
|
|
||||||
cp ../conf/biboumi.cfg /etc/biboumi/
|
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="${port}" --target_file="$biboumi_config_file"
|
|
||||||
ynh_replace_string --match_string="__ADMIN_JID__" --replace_string="${admin_jid}" --target_file="$biboumi_config_file"
|
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
|
||||||
ynh_store_file_checksum "$biboumi_config_file"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE METRONOME COMPONENT
|
# UPGRADE METRONOME COMPONENT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading Metronome component..."
|
||||||
|
|
||||||
# Upgrade metronome component
|
# Upgrade metronome component
|
||||||
cp ../conf/biboumi.cfg.lua /etc/metronome/conf.d/
|
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
ynh_replace_string --match_string="__DOMAIN__" --replace_string="${domain}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
|
|
||||||
ynh_replace_string --match_string="__SECRET__" --replace_string="${shared_secret}" --target_file="/etc/metronome/conf.d/biboumi.cfg.lua"
|
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=metronome --action="restart"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# CREATE DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
|
ynh_script_progression --message="Creating a data directory..."
|
||||||
|
|
||||||
# Use logrotate to manage app-specific logfile(s)
|
mkdir -p /var/lib/$app
|
||||||
ynh_use_logrotate /var/log/biboumi/ --non-append
|
|
||||||
|
# Set permissions to app files
|
||||||
|
chown -R _biboumi:_biboumi "/var/lib/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPDATE A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating a configuration file..."
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
|
||||||
|
|
||||||
|
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
||||||
|
|
||||||
# Set permissions on app files
|
mkdir -p /var/log/$app
|
||||||
chown _biboumi /var/log/biboumi /var/lib/biboumi /etc/biboumi
|
chown -R _biboumi:_biboumi "/var/log/$app"
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
|
||||||
yunohost service add biboumi --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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD SERVICES
|
# START 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=$app
|
||||||
ynh_systemd_action --action=restart --service_name=biboumi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of Biboumi completed" --last
|
ynh_script_progression --message="Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue