1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/horde_ynh.git synced 2024-09-03 19:16:08 +02:00
horde_ynh/scripts/change_url

115 lines
3.7 KiB
Text
Raw Normal View History

2018-02-06 14:33:23 +01:00
#!/bin/bash
2018-02-11 00:32:26 +01:00
#=================================================
2022-03-09 00:27:32 +01:00
# GENERIC STARTING
2018-02-11 00:32:26 +01:00
#=================================================
2018-02-06 14:33:23 +01:00
# IMPORT GENERIC HELPERS
2022-03-09 00:27:32 +01:00
#=================================================
2018-02-06 14:33:23 +01:00
2022-03-09 00:27:32 +01:00
source _common.sh
source /usr/share/yunohost/helpers
2022-03-09 00:27:32 +01:00
#=================================================
2018-02-06 14:33:23 +01:00
# RETRIEVE ARGUMENTS
2022-03-09 00:27:32 +01:00
#=================================================
2018-02-06 14:33:23 +01:00
old_domain=$YNH_APP_OLD_DOMAIN
2018-07-31 18:48:46 +02:00
domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path --path_url ${YNH_APP_NEW_PATH:-'/'})
2018-02-06 14:33:23 +01:00
app=$YNH_APP_INSTANCE_NAME
2022-03-09 00:27:32 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
service_autodiscovery=$(ynh_app_setting_get --app=$app --key=service_autodiscovery)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
2018-02-06 14:33:23 +01:00
2018-02-11 00:32:26 +01:00
#=================================================
2022-03-09 00:27:32 +01:00
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
2018-02-11 00:32:26 +01:00
#=================================================
2022-03-09 00:27:32 +01:00
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
2018-02-11 00:32:26 +01:00
2022-03-09 00:27:32 +01:00
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
2022-03-09 00:27:32 +01:00
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
2018-02-06 14:33:23 +01:00
# MODIFY URL IN NGINX CONF
2022-03-09 00:27:32 +01:00
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
2018-02-06 14:33:23 +01:00
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
2022-03-09 00:27:32 +01:00
# Change the domain for NGINX
2018-07-31 18:48:46 +02:00
if [ "$old_domain" != "$domain" ]
2018-02-06 14:33:23 +01:00
then
# Delete file checksum for the old conf file location
2022-03-09 00:27:32 +01:00
ynh_delete_file_checksum --file="$nginx_conf_path"
2018-07-31 18:48:46 +02:00
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
2018-02-06 14:33:23 +01:00
# Store file checksum for the new config file location
2022-03-09 00:27:32 +01:00
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf"
2018-02-06 14:33:23 +01:00
fi
2022-03-09 00:27:32 +01:00
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
2018-02-06 14:33:23 +01:00
config_nginx
# Update horde config
ynh_script_progression --message="Configuring application..." --weight=3
2018-02-06 14:33:23 +01:00
config_horde
2022-03-09 00:27:32 +01:00
#=================================================
# GENERIC FINALISATION
#=================================================
2018-02-06 14:33:23 +01:00
# RELOAD NGINX
2022-03-09 00:27:32 +01:00
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2022-03-09 00:27:32 +01:00
ynh_script_progression --message="Change of URL completed for $app"