mirror of
https://github.com/YunoHost-Apps/sogo_ynh.git
synced 2024-09-03 20:26:07 +02:00
89 lines
2.1 KiB
Bash
Executable file
89 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
|
|
# Source YunoHost helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Stop script if errors
|
|
ynh_abort_if_errors
|
|
|
|
# Import common cmd
|
|
source ./experimental_helper.sh
|
|
source ./_common.sh
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
admin=$YNH_APP_ARG_ADMIN
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
|
|
# Set variable
|
|
path_url="/SOGo"
|
|
# final_path="/opt/yunohost/$app"
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
ynh_app_setting_set $app admin $admin
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
# Check web path availability
|
|
ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path."
|
|
# Register (book) web path
|
|
ynh_webpath_register $app $domain $path_url
|
|
|
|
# Find a port for SOGo
|
|
port=$(ynh_find_port 20000)
|
|
ynh_app_setting_set $app web_port $port
|
|
smtp_port=$(ynh_find_port $((port+1)))
|
|
ynh_app_setting_set $app smtp_port $smtp_port
|
|
|
|
#=================================================
|
|
# STANDARD MODIFICATIONS
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
install_dependance
|
|
|
|
# CREATE A MYSQL DATABASE
|
|
db_name=$(ynh_sanitize_dbid $app)
|
|
db_user=$db_name
|
|
ynh_app_setting_set $app db_name $db_name
|
|
ynh_app_setting_set $app db_user $db_user
|
|
db_pwd=$(ynh_string_random 15)
|
|
ynh_mysql_setup_db $db_name $db_user $db_pwd
|
|
|
|
# Configure SOGO
|
|
config_sogo
|
|
|
|
# Configure stunnel
|
|
# To fix the issue https://sogo.nu/bugs/view.php?id=31 we need stunnel to be able to connect correctly to the smtp server
|
|
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
|
|
|
|
# Restart services
|
|
systemctl restart sogo
|
|
systemctl restart stunnel4
|