#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) backend_path=$(ynh_app_setting_get --app=$app --key=backend_path) port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) secret=$(ynh_string_random --length=32) timezone="$(cat /etc/timezone)" set_motd=$(ynh_app_setting_get --app=$app --key=set_motd) enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration) enable_linksharing=$(ynh_app_setting_get --app=$app --key=enable_linksharing) enable_taskattachments=$(ynh_app_setting_get --app=$app --key=enable_taskattachments) enable_taskcomments=$(ynh_app_setting_get --app=$app --key=enable_taskcomments) enable_emailreminders=$(ynh_app_setting_get --app=$app --key=enable_emailreminders) enable_userdeletion=$(ynh_app_setting_get --app=$app --key=enable_userdeletion) maxavatarsize=$(ynh_app_setting_get --app=$app --key=maxavatarsize) maxitemsperpage=$(ynh_app_setting_get --app=$app --key=maxitemsperpage) #================================================= # STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the NGINX config file if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" # Create a dedicated NGINX config ynh_add_nginx_config fi # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 domain="$new_domain" path="$new_path" redis_db=$(ynh_redis_get_free_db) ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml" chmod 600 "$backend_path/config.yml" #================================================= # GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action=start --log_path=systemd #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Change of URL completed for $app" --last