reverseproxy_ynh/scripts/change_url

49 lines
1.3 KiB
Text
Raw Normal View History

2023-01-08 14:33:31 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
source _common.sh
#=================================================
# REVERSEPROXY_YNH
2023-01-08 14:33:31 +01:00
#=================================================
# Nginx configuration
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
2023-11-25 19:23:56 +01:00
2023-11-25 19:16:11 +01:00
path="$new_path"
domain="$old_domain"
# Validate reverse proxy destination
rp_validate_proxy_path
# Validate assets_path
rp_validate_assets_path
2023-11-25 19:16:11 +01:00
# Special case for "/" path
rp_handle_webroot
2023-11-25 19:23:56 +01:00
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
2023-11-25 19:23:56 +01:00
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
ynh_add_nginx_config
# Move file to new domain if domain has changed
2023-11-25 19:23:56 +01:00
if [[ "$old_domain" != "$new_domain" ]]; then
new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf
ynh_delete_file_checksum --file="$nginx_conf_path"
mv "${nginx_conf_path}" "${new_nginx_conf_path}"
2023-11-25 19:23:56 +01:00
ynh_store_file_checksum --file="$new_nginx_conf_path"
fi
2023-01-08 14:33:31 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Changing URL of $app completed" --last