mirror of
https://github.com/YunoHost-Apps/reverseproxy_ynh.git
synced 2024-09-03 20:16:23 +02:00
53 lines
1.8 KiB
Text
53 lines
1.8 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
#=================================================
|
||
|
# GENERIC START
|
||
|
#=================================================
|
||
|
# IMPORT GENERIC HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
source /usr/share/yunohost/helpers
|
||
|
source _common.sh
|
||
|
|
||
|
#=================================================
|
||
|
# MANAGE SCRIPT FAILURE
|
||
|
#=================================================
|
||
|
|
||
|
# Exit if an error occurs during the execution of the script
|
||
|
ynh_abort_if_errors
|
||
|
|
||
|
#=================================================
|
||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||
|
#=================================================
|
||
|
|
||
|
app=$YNH_APP_INSTANCE_NAME
|
||
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||
|
new_domain=$YNH_APP_NEW_DOMAIN
|
||
|
old_path=$YNH_APP_OLD_PATH
|
||
|
new_path=$YNH_APP_NEW_PATH
|
||
|
|
||
|
# Path availability is already checked for
|
||
|
|
||
|
#=================================================
|
||
|
# CONFIGURE NGINX
|
||
|
#=================================================
|
||
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||
|
|
||
|
# Nginx configuration
|
||
|
ynh_replace_string "$old_path {" "$new_path {" /etc/nginx/conf.d/$old_domain.d/$app.conf
|
||
|
ynh_replace_string "${old_path}/ {" "${new_path}/ {" /etc/nginx/conf.d/$old_domain.d/$app.conf
|
||
|
ynh_replace_string "302 ${old_path}/" "302 ${new_path}/" /etc/nginx/conf.d/$old_domain.d/$app.conf
|
||
|
|
||
|
# Maybe only path part has changed... only move file if domain has changed
|
||
|
[[ "$old_domain" != "$new_domain" ]] && mv /etc/nginx/conf.d/$old_domain.d/$app.conf /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||
|
|
||
|
# Reload nginx
|
||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||
|
rp_reload_web
|
||
|
|
||
|
#=================================================
|
||
|
# END OF SCRIPT
|
||
|
#=================================================
|
||
|
|
||
|
ynh_script_progression --message="Changing URL of $app completed" --last
|