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

64 lines
2.4 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
#=================================================
# CREATE DIRECTORIES
#=================================================
ynh_script_progression --message="Setting up the data directory..."
# Set permissions to app files
chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
# Upgrade metronome component
metronome_config_dir=$(_get_metronome_config_dir)
ynh_add_config --template="metronome.cfg.lua" --destination="$metronome_config_dir/$app.cfg.lua"
chown metronome:metronome "$metronome_config_dir/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
# Upgrade biboumi configuration
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated systemd config
systemctl enable "$app.service" --quiet
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)
ynh_use_logrotate --non-append
chown -R _biboumi:_biboumi "/var/log/$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="start" --line_match="Authenticated with the XMPP server" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"