1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00
dotclear2_ynh/scripts/change_url

52 lines
1.8 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE THE DATABASE
#=================================================
ynh_script_progression "Updating database..."
new_index_url="${new_path%/}/index.php"
new_public_url="${new_path%/}/public"
new_themes_url="${new_path%/}/themes"
ynh_mysql_db_shell <<< "UPDATE dc_blog SET blog_url='https://$new_domain$new_index_url?' WHERE dc_blog.blog_id='default'"
ynh_mysql_db_shell <<< "UPDATE dc_setting SET setting_value='$new_public_url' WHERE dc_setting.setting_id='public_url'"
ynh_mysql_db_shell <<< "UPDATE dc_setting SET setting_value='$new_themes_url' WHERE dc_setting.setting_id='themes_url'"
#=================================================
# UPDATE CONFIGURATION
#=================================================
ynh_script_progression "Updating configuration file..."
php_config=$install_dir/inc/config.php
ynh_backup_if_checksum_is_different "$php_config"
new_admin_url="${new_path%/}/admin/"
old_admin_url="${old_path%/}/admin/"
ynh_replace --match="'DC_ADMIN_URL', 'https://$old_domain$old_admin_url'" --replace="'DC_ADMIN_URL', 'https://$new_domain$new_admin_url'" --file=$php_config
ynh_store_file_checksum "$php_config"
chmod 400 "$php_config"
chown $app:$app "$php_config"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"