1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00
sogo_ynh/scripts/upgrade

80 lines
3 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# UPGRADE SETTINGS FROM OLD INSTALL
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Manage migrations
ynh_script_progression --message="Migrating database if needed..."
if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then
ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh
bash migrations/3.2-4.0.sh
fi
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Configuring application..." --weight=1
# Configure SOGO
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
chown -R "$app:$app" "/etc/$app"
chmod -R 750 "/etc/$app"
# Configure stunnel
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
# Enable stunnel at startup
ynh_replace_string --match_string="ENABLED=0" --replace_string="ENABLED=1" --target_file="/etc/default/stunnel4"
# Protect logs dir
chown -R "$app:$app" "/var/log/$app"
chmod -R 750 "/var/log/$app"
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setting up a cron..." --weight=1
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
config_nginx
yunohost service add "$app" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
ynh_systemd_action --service_name="stunnel4" --action="restart" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last