#!/bin/bash

#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping systemd service '$app'..."

ynh_systemd_action --service_name="$app" --action="stop"

#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."

ynh_change_url_nginx_config

#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# MODIFY SETTINGS
#=================================================
ynh_script_progression --message="Modify $app config file..."

ynh_add_config --template="settings.py" --destination="$install_dir/settings.py"

#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting systemd service '$app'..." --weight=5

ynh_systemd_action --service_name="$app" --action="start"

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Change of URL completed for $app" --last