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

90 lines
2.1 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
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
# STORE SETTINGS FROM MANIFEST
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public
2016-03-18 18:38:54 +01:00
2018-08-14 22:18:22 +02:00
# 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
2016-03-18 18:38:54 +01:00
2018-08-14 22:18:22 +02:00
# 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
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
install_dependance
2016-03-18 18:38:54 +01:00
2018-08-14 22:18:22 +02:00
# 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
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
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
set_permission
2016-03-18 18:38:54 +01:00
2018-08-14 22:18:22 +02:00
# 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 "/"
2016-03-18 18:38:54 +01:00
fi
2018-08-14 22:18:22 +02:00
# SETUP LOGROTATE
2018-09-01 23:31:06 +02:00
ynh_use_logrotate /var/log/$app/sogo.log --non-append
2016-03-18 18:38:54 +01:00
# Restart services
2018-08-14 22:18:22 +02:00
systemctl restart sogo
systemctl restart stunnel4