2023-05-29 11:46:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
|
|
|
|
ynh_change_url_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHANGE THE URL IN .ENV.LOCAL AND REBUILD THE APP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Setting the new URL..." --weight=1
|
|
|
|
|
|
|
|
if [ $change_domain -eq 1 ]
|
|
|
|
then
|
2023-05-30 16:24:39 +02:00
|
|
|
ynh_replace_string --match_string="NEXT_PUBLIC_SITE_DOMAIN=$old_domain$old_path" --replace_string="NEXT_PUBLIC_SITE_DOMAIN=$new_domain$new_path" --target_file="$install_dir/.env.local"
|
2023-05-29 11:46:05 +02:00
|
|
|
fi
|
|
|
|
|
2023-05-29 16:28:58 +02:00
|
|
|
if [ $change_path -eq 1 ]
|
|
|
|
then
|
|
|
|
if [ "$old_path" = "/" ]; then
|
|
|
|
old_next_path=""
|
|
|
|
else
|
|
|
|
old_next_path=$old_path
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$new_path" = "/" ]; then
|
|
|
|
new_next_path=""
|
2023-05-31 05:56:08 +02:00
|
|
|
next_path=""
|
2023-05-29 16:28:58 +02:00
|
|
|
else
|
|
|
|
new_next_path=$new_path
|
2023-05-31 05:56:08 +02:00
|
|
|
next_path=$new_path
|
2023-05-29 16:28:58 +02:00
|
|
|
fi
|
|
|
|
|
2023-05-31 05:56:08 +02:00
|
|
|
ynh_add_config --template="manifest.json" --destination="$install_dir/public/manifest.json"
|
|
|
|
|
|
|
|
ynh_add_config --template="next.config.js" --destination="$install_dir/next.config.js"
|
2023-05-30 15:11:28 +02:00
|
|
|
|
|
|
|
ynh_replace_string --match_string="src={useColorModeValue(\"$old_next_path/banner_light.svg\", \"$old_next_path/banner_dark.svg\")}" --replace_string="src={useColorModeValue(\"$new_next_path/banner_light.svg\", \"$new_next_path/banner_dark.svg\")}" --target_file="$install_dir/components/Header.tsx"
|
2023-05-30 16:24:39 +02:00
|
|
|
|
|
|
|
ynh_replace_string --match_string="href=\"$old_next_path/favicon" --replace_string="href=\"$new_next_path/favicon" --target_file="$install_dir/components/CustomHead.tsx"
|
|
|
|
|
|
|
|
ynh_replace_string --match_string="href=\"$old_next_path/apple" --replace_string="href=\"$new_next_path/apple" --target_file="$install_dir/components/CustomHead.tsx"
|
|
|
|
|
2023-05-30 16:46:37 +02:00
|
|
|
ynh_replace_string --match_string="href=\"$old_next_path/manifest" --replace_string="href=\"$new_next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx"
|
2023-05-29 16:28:58 +02:00
|
|
|
fi
|
|
|
|
|
2023-05-29 12:24:24 +02:00
|
|
|
#=================================================
|
|
|
|
# REBUILDING AND INSTALL THE APP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Rebuilding the app..." --weight=1
|
|
|
|
|
2023-05-30 12:34:40 +02:00
|
|
|
ynh_exec_warn_less yarn --cwd "$install_dir" build
|
2023-05-29 11:46:05 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Change of URL completed for $app" --last
|