my_idlers_ynh/scripts/change_url
2025-03-03 22:10:40 +01:00

44 lines
1.6 KiB
Bash

#!/bin/bash
## new location is available via $domain and $path (or $new_domain and $new_path variables if you want to be explicit)
## old values are available via, you guessed it, $old_domain and $old_path
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
## My Idlers runs as a Laravel app on nginx; keep nginx running, so no stop
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
# this will most likely adjust NGINX config correctly
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
## Only the app_url in .env needs to change
sed -i -e 's/$old_domain/new_domain/g' $install_dir/.env
sed -i -e 's/$old_path/new_path/g' $install_dir/.env
## perhaps a better option than sed: ynh_replace + ynh_store_file_checksum; try it out later
# ynh_replace --match=$old_domain --replace="$new_domain --file="$install_dir/.env"
# ynh_replace --match=$old_path --replace="$new_path --file="$install_dir/.env"
ynh_store_file_checksum "$install_dir/.env"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"