2019-12-17 16:47:29 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# MODIFY URL IN NGINX CONF
|
|
|
|
#=================================================
|
2021-05-15 16:10:33 +02:00
|
|
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2023-08-15 17:52:30 +02:00
|
|
|
ynh_change_url_nginx_config
|
2019-12-17 16:47:29 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# UPDATE THE DATABASE
|
|
|
|
#=================================================
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_script_progression --message="Updating database..."
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2020-04-17 14:38:01 +02:00
|
|
|
new_index_url="${new_path%/}/index.php"
|
|
|
|
new_public_url="${new_path%/}/public"
|
|
|
|
new_themes_url="${new_path%/}/themes"
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_mysql_execute_as_root --sql="UPDATE dc_blog SET blog_url='https://$new_domain$new_index_url?' WHERE dc_blog.blog_id='default'" --database=$db_name
|
|
|
|
ynh_mysql_execute_as_root --sql="UPDATE dc_setting SET setting_value='$new_public_url' WHERE dc_setting.setting_id='public_url'" --database=$db_name
|
|
|
|
ynh_mysql_execute_as_root --sql="UPDATE dc_setting SET setting_value='$new_themes_url' WHERE dc_setting.setting_id='themes_url'" --database=$db_name
|
2019-12-17 16:47:29 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPDATE CONFIGURATION
|
|
|
|
#=================================================
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_script_progression --message="Updating configuration file..."
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2023-08-15 17:52:30 +02:00
|
|
|
php_config=$install_dir/inc/config.php
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_backup_if_checksum_is_different --file="$php_config"
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2021-09-14 11:01:12 +02:00
|
|
|
new_admin_url="${new_path%/}/admin/"
|
|
|
|
old_admin_url="${old_path%/}/admin/"
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_replace_string --match_string="'DC_ADMIN_URL', 'https://$old_domain$old_admin_url'" --replace_string="'DC_ADMIN_URL', 'https://$new_domain$new_admin_url'" --target_file=$php_config
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_store_file_checksum --file="$php_config"
|
2019-12-17 16:47:29 +01:00
|
|
|
|
2021-05-17 22:07:08 +02:00
|
|
|
chmod 400 "$php_config"
|
|
|
|
chown $app:$app "$php_config"
|
|
|
|
|
2019-12-17 16:47:29 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-04-17 14:38:01 +02:00
|
|
|
ynh_script_progression --message="Change of URL completed for $app" --last
|