2018-08-14 22:18:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SET ALL CONSTANTS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DEFINE ALL COMMON FONCTIONS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
install_dependance() {
|
2019-10-09 17:47:59 +02:00
|
|
|
ynh_install_app_dependencies sogo stunnel4 memcached
|
2018-08-14 22:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config_sogo() {
|
2018-08-31 14:34:25 +02:00
|
|
|
# Avoid if the directory don't exist
|
|
|
|
mkdir -p /etc/$app
|
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_backup_if_checksum_is_different --file /etc/$app/sogo.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
cp ../conf/sogo.conf /etc/$app/sogo.conf
|
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string __APP__ --replace_string $app --target_file /etc/$app/sogo.conf
|
|
|
|
ynh_replace_string --match_string __ADMINUSER__ --replace_string $admin --target_file /etc/$app/sogo.conf
|
|
|
|
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file /etc/$app/sogo.conf
|
|
|
|
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file /etc/$app/sogo.conf
|
|
|
|
ynh_replace_string --match_string __PORT__ --replace_string $port --target_file /etc/$app/sogo.conf
|
|
|
|
ynh_replace_string --match_string __SMTP_PORT__ --replace_string $smtp_port --target_file /etc/$app/sogo.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_store_file_checksum --file /etc/$app/sogo.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config_stunnel() {
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_backup_if_checksum_is_different --file /etc/stunnel/$app.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
cp ../conf/stunnel.conf /etc/stunnel/$app.conf
|
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string __SMTP_PORT__ --replace_string $smtp_port --target_file /etc/stunnel/$app.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_store_file_checksum --file /etc/stunnel/$app.conf
|
2018-08-14 22:18:22 +02:00
|
|
|
|
|
|
|
# Enable stunnel at startup
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
|
2018-08-14 22:18:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config_cron() {
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_backup_if_checksum_is_different --file /etc/cron.d/$app
|
2018-08-14 22:18:22 +02:00
|
|
|
|
|
|
|
cp ../conf/cron /etc/cron.d/$app
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_replace_string --match_string __APP__ --replace_string $app --target_file /etc/cron.d/$app
|
|
|
|
ynh_store_file_checksum --file /etc/cron.d/$app
|
2018-08-14 22:18:22 +02:00
|
|
|
systemctl restart cron
|
|
|
|
}
|
|
|
|
|
|
|
|
config_nginx() {
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
nginx_domain_path=/etc/nginx/conf.d/$domain.d/*
|
|
|
|
nginx_config_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
grep "/principals" $nginx_domain_path || echo "# For IOS 7
|
|
|
|
location = /principals/ {
|
|
|
|
rewrite ^ https://\$server_name/SOGo/dav;
|
|
|
|
allow all;
|
|
|
|
}
|
|
|
|
" >> "$nginx_config_path"
|
|
|
|
|
|
|
|
grep "/Microsoft-Server-ActiveSync" $nginx_domain_path || echo "# For ActiveSync
|
|
|
|
location /Microsoft-Server-ActiveSync/ {
|
|
|
|
proxy_pass http://127.0.0.1:$port/SOGo/Microsoft-Server-ActiveSync/;
|
|
|
|
}
|
|
|
|
" >> "$nginx_config_path"
|
|
|
|
|
2019-02-08 10:21:19 +01:00
|
|
|
grep "/.well-known/caldav" $nginx_domain_path || echo "# For Caldav
|
|
|
|
location /.well-known/caldav {
|
2019-01-29 09:19:08 +01:00
|
|
|
rewrite ^ https://\$server_name/SOGo/dav/;
|
|
|
|
}
|
2019-02-08 10:21:19 +01:00
|
|
|
" >> "$nginx_config_path"
|
2019-01-29 09:19:08 +01:00
|
|
|
|
2019-02-08 10:21:19 +01:00
|
|
|
grep "/.well-known/carddav" $nginx_domain_path || echo "# For Carddav
|
|
|
|
location /.well-known/carddav {
|
2019-01-29 09:19:08 +01:00
|
|
|
rewrite ^ https://\$server_name/SOGo/dav/;
|
|
|
|
}
|
2019-02-08 10:21:19 +01:00
|
|
|
" >> "$nginx_config_path"
|
2019-01-29 09:19:08 +01:00
|
|
|
|
2019-06-07 23:09:30 +02:00
|
|
|
ynh_store_file_checksum --file "$nginx_config_path"
|
2018-08-14 22:18:22 +02:00
|
|
|
|
|
|
|
systemctl reload nginx
|
|
|
|
}
|
|
|
|
|
|
|
|
set_permission() {
|
|
|
|
chown -R $app:$app /etc/$app
|
2018-09-01 23:31:06 +02:00
|
|
|
chmod u=rwX,g=rX,o= -R /etc/$app
|
2018-08-14 22:18:22 +02:00
|
|
|
chown -R $app:$app /var/log/$app
|
2018-09-01 23:31:06 +02:00
|
|
|
chmod u=rwX,g=rX,o= -R /var/log/$app
|
2018-08-31 14:34:25 +02:00
|
|
|
}
|