2016-03-18 18:38:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2020-11-17 23:55:57 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./experimental_helper.sh
|
|
|
|
source ./_common.sh
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Validating installation parameters..."
|
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
|
|
|
admin=$YNH_APP_ARG_ADMIN
|
|
|
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Set variable
|
|
|
|
path_url="/SOGo"
|
|
|
|
# final_path="/opt/yunohost/$app"
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Register (book) web path
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_webpath_register --app $app --domain $domain --path_url $path_url
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Find a port for SOGo
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Finding available ports..."
|
|
|
|
port=$(ynh_find_port --port 20000)
|
|
|
|
smtp_port=$(ynh_find_port --port $((port+1)))
|
|
|
|
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
ynh_script_progression --message="Storing installation settings..."
|
|
|
|
ynh_app_setting_set --app $app --key admin --value $admin
|
|
|
|
ynh_app_setting_set --app $app --key is_public --value $is_public
|
|
|
|
ynh_app_setting_set --app $app --key smtp_port --value $smtp_port
|
|
|
|
ynh_app_setting_set --app $app --key web_port --value $port
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# INSTALL DEPENDENCIES
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Installing dependencies..." --weight=7
|
2018-08-14 22:18:22 +02:00
|
|
|
install_dependance
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# CREATE A MYSQL DATABASE
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring MySQL database..."
|
2018-08-14 22:18:22 +02:00
|
|
|
db_name=$(ynh_sanitize_dbid $app)
|
|
|
|
db_user=$db_name
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_app_setting_set --app $app --key db_name --value $db_name
|
|
|
|
ynh_app_setting_set --app $app --key db_user --value $db_user
|
|
|
|
ynh_mysql_setup_db --db_name $db_name --db_user $db_user
|
|
|
|
|
|
|
|
ynh_script_progression --message="Configuring application..." --weight=3
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Configure SOGO
|
|
|
|
config_sogo
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# 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
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# Install crontab
|
|
|
|
config_cron
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2016-03-18 20:36:22 +01:00
|
|
|
#Configure Nginx
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring nginx..." --weight=1
|
2018-08-14 22:18:22 +02:00
|
|
|
config_nginx
|
2016-03-18 20:36:22 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# SECURE FILES AND DIRECTORIES
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Protecting directory..."
|
2018-08-14 22:18:22 +02:00
|
|
|
set_permission
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# configure the sso
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring permissions..."
|
2018-08-14 22:18:22 +02:00
|
|
|
if [ "$is_public" = "0" ];
|
|
|
|
then # Retire l'accès public
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_app_setting_delete --app $app --key skipped_uris
|
2018-08-14 22:18:22 +02:00
|
|
|
else
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_app_setting_set --app $app --key unprotected_uris --value "/"
|
2016-03-18 18:38:54 +01:00
|
|
|
fi
|
2019-02-08 10:21:19 +01:00
|
|
|
python3 add_sso_conf.py
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2018-08-14 22:18:22 +02:00
|
|
|
# SETUP LOGROTATE
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Configuring log rotation..."
|
2019-11-04 20:27:16 +01:00
|
|
|
ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend
|
2016-03-18 18:38:54 +01:00
|
|
|
|
2020-05-24 00:32:03 +02:00
|
|
|
# Register service
|
|
|
|
yunohost service add $app --log "/var/log/$app/sogo.log"
|
|
|
|
|
2016-03-18 18:38:54 +01:00
|
|
|
# Restart services
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_script_progression --message="Starting sogo services..." --weight=3
|
2018-08-14 22:18:22 +02:00
|
|
|
systemctl restart sogo
|
|
|
|
systemctl restart stunnel4
|
2019-06-07 23:09:30 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|