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/install

103 lines
3 KiB
Text
Raw Normal View History

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
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
2018-08-14 22:18:22 +02:00
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
2016-03-18 18:38:54 +01: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
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
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
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
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
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
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
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
ynh_script_progression --message="Configuring permissions..."
2018-08-14 22:18:22 +02:00
if [ "$is_public" = "0" ];
then # Retire l'accès public
ynh_app_setting_delete --app $app --key skipped_uris
2018-08-14 22:18:22 +02:00
else
ynh_app_setting_set --app $app --key unprotected_uris --value "/"
2016-03-18 18:38:54 +01:00
fi
python3 add_sso_conf.py
2016-03-18 18:38:54 +01:00
2018-08-14 22:18:22 +02:00
# SETUP LOGROTATE
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/$app/sogo.log --non-append
2016-03-18 18:38:54 +01:00
# Restart services
ynh_script_progression --message="Starting sogo services..." --weight=3
2018-08-14 22:18:22 +02:00
systemctl restart sogo
systemctl restart stunnel4
ynh_script_progression --message="Installation of $app completed" --last