2016-03-18 18:38:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2018-08-14 22:18:22 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE SETTINGS FROM OLD INSTALL
|
|
|
|
#=================================================
|
2022-01-15 12:05:29 +01:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2022-05-28 14:59:15 +02:00
|
|
|
# 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
|
|
|
|
|
2022-01-15 10:12:54 +01:00
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2022-01-15 12:10:50 +01:00
|
|
|
ynh_script_progression --message="Configuring application..." --weight=1
|
2019-06-07 23:09:30 +02:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Configure SOGO
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
|
|
|
|
chown -R "$app:$app" "/etc/$app"
|
|
|
|
chmod -R 750 "/etc/$app"
|
2018-08-14 22:18:22 +02:00
|
|
|
|
|
|
|
# Configure stunnel
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
|
2022-01-15 12:06:50 +01:00
|
|
|
|
|
|
|
# Enable stunnel at startup
|
|
|
|
ynh_replace_string --match_string="ENABLED=0" --replace_string="ENABLED=1" --target_file="/etc/default/stunnel4"
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2024-01-30 23:33:35 +01:00
|
|
|
# Protect logs dir
|
|
|
|
chown -R "$app:$app" "/var/log/$app"
|
|
|
|
chmod -R 750 "/var/log/$app"
|
|
|
|
|
2022-01-15 10:05:56 +01:00
|
|
|
#=================================================
|
|
|
|
# SETUP A CRON
|
|
|
|
#=================================================
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_script_progression --message="Setting up a cron..." --weight=1
|
2022-01-15 10:05:56 +01:00
|
|
|
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
2022-01-15 10:05:56 +01:00
|
|
|
chown root: "/etc/cron.d/$app"
|
|
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
2024-01-30 23:33:35 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2024-01-30 23:33:35 +01:00
|
|
|
config_nginx
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2024-01-30 23:33:35 +01:00
|
|
|
yunohost service add "$app" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
|
2022-01-15 10:11:21 +01:00
|
|
|
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
2022-06-18 12:05:22 +02:00
|
|
|
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2022-01-15 10:09:18 +01:00
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
2024-01-30 23:33:35 +01:00
|
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
|
|
|
ynh_systemd_action --service_name="stunnel4" --action="restart" --log_path="systemd"
|
2019-06-07 23:09:30 +02:00
|
|
|
|
2022-01-14 23:57:33 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|