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
|
2020-03-25 23:00:34 +01:00
|
|
|
mkdir -p /etc/$app
|
|
|
|
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
|
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..."
|
2020-03-25 23:00:34 +01:00
|
|
|
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
|
|
|
|
--label="Sync client" --protected=true --show_tile=false\
|
|
|
|
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
|
|
|
|
|
|
|
|
if [ "$is_public" == '1' ];
|
|
|
|
then
|
|
|
|
ynh_permission_update --permission "main" --add "visitors"
|
2016-03-18 18:38:54 +01:00
|
|
|
fi
|
|
|
|
|
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
|