mirror of
https://github.com/YunoHost-Apps/sogo_ynh.git
synced 2024-09-03 20:26:07 +02:00
96 lines
4.1 KiB
Bash
Executable file
96 lines
4.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# UPGRADE SETTINGS FROM OLD INSTALL
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# Manage migrations
|
|
ynh_script_progression --message="Migrating database if needed..."
|
|
|
|
if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then
|
|
ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh
|
|
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh
|
|
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh
|
|
bash migrations/3.2-4.0.sh
|
|
fi
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring application..." --weight=1
|
|
|
|
# Configure SOGO
|
|
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
|
|
chown -R "$app:$app" "/etc/$app"
|
|
chmod -R 750 "/etc/$app"
|
|
|
|
# Configure stunnel
|
|
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
|
|
|
|
# Enable stunnel at startup
|
|
ynh_replace_string --match_string="ENABLED=0" --replace_string="ENABLED=1" --target_file="/etc/default/stunnel4"
|
|
|
|
# Protect logs dir
|
|
chown -R "$app:$app" "/var/log/$app"
|
|
chmod -R 750 "/var/log/$app"
|
|
|
|
#=================================================
|
|
# SETUP A CRON
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up a cron..." --weight=1
|
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
# # configure the sso
|
|
# #REMOVEME? ynh_script_progression --message="Configuring permissions..."
|
|
|
|
# #REMOVEME? if ! ynh_permission_exists --permission sync_client; then
|
|
# #REMOVEME? ynh_permission_create --permission="sync_client" --allowed 'visitors' --auth_header=false\
|
|
# --label="Sync client" --protected=true --show_tile=false\
|
|
# --additional_urls="$domain/Microsoft-Server-ActiveSync" "$domain/principals" "$domain/.well-known/caldav" "$domain/.well-known/carddav"
|
|
# python3 remove_sso_conf_persistent.py $domain \
|
|
# || ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
|
|
# else
|
|
# #REMOVEME? ynh_permission_update --permission="sync_client" --add='visitors' --label="Sync client" --protected=true --show_tile=false
|
|
# ynh_permission_url --permission "sync_client" --clear_urls
|
|
# ynh_permission_url --permission "sync_client" --auth_header=false\
|
|
# --add_url="$domain/Microsoft-Server-ActiveSync" "$domain/principals" "$domain/.well-known/caldav" "$domain/.well-known/carddav"
|
|
# fi
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
config_nginx
|
|
|
|
yunohost service add "$app" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
|
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd"
|
|
ynh_systemd_action --service_name="stunnel4" --action="restart" --log_path="systemd"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|