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
2018-08-31 14:29:42 +02:00

112 lines
2.4 KiB
Bash
Executable file

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# LOAD SETTINGS
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
admin=$(ynh_app_setting_get $app admin)
is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app web_port)
smtp_port=$(ynh_app_setting_get $app smtp_port)
db_name=$(ynh_app_setting_get $app db_name)
db_user=$(ynh_app_setting_get $app db_user)
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# UPGRADE SETTINGS FROM OLD INSTALL
#=================================================
if [[ ${is_public,,*} = "yes" ]]
then
is_public=1
ynh_app_setting_set $app is_public 1
fi
if [[ ${is_public,,*} = "no" ]]
then
is_public=0
ynh_app_setting_set $app is_public 0
fi
if [[ -z $port ]]
then
# Find a port for SOGo
port=$(ynh_find_port 20000)
ynh_app_setting_set $app web_port $port
fi
if [[ -z $db_name ]]
then
db_name=$app
ynh_app_setting_set $app db_name $db_name
fi
if [[ -z $db_user ]]
then
db_user=$app
ynh_app_setting_set $app db_user $db_user
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
install_dependance
# Configure SOGO
config_sogo
# Configure stunnel
config_stunnel
# Install crontab
config_cron
#Configure Nginx
config_nginx
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
set_permission
# configure the sso
if [ "$is_public" = "0" ];
then # Retire l'accès public
ynh_app_setting_delete $app skipped_uris
else
ynh_app_setting_set $app unprotected_uris "/"
fi
# SETUP LOGROTATE
ynh_use_logrotate /var/log/$app/sogo.log --non-append $app/$app
# Restart services
systemctl restart sogo
systemctl restart stunnel4