1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wallabag2_ynh.git synced 2024-10-01 13:35:06 +02:00
wallabag2_ynh/scripts/change_url
eric_G 95022ac475
Testing (#207)
* Fix hook (#206)

* Auto-update READMEs

* fix hook

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Update manifest.toml (#208)

* Update manifest.toml

* Auto-update READMEs

* Add parameters.yml (#209)

* Add parameters.yml

* Update upgrade

* Update change_url

* Function (#210)

* Add parameters.yml

* Update upgrade

* add function

---------

Co-authored-by: Kayou <pierre@kayou.io>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
2024-07-22 21:05:52 +02:00

49 lines
2.1 KiB
Bash

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
ynh_change_url_nginx_config
#=================================================
# UPDATE CONFIGURATION
#=================================================
ynh_script_progression --message="Updating wallabag configuration..."
# Configure Wallabag instance URL
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \
<<< "UPDATE internal_setting SET value = 'https://$new_domain$new_path' WHERE name = 'wallabag_url'"
# Change domain name in parameters.yml
ynh_replace_string --target_file="$install_dir/app/config/parameters.yml" --match_string="domain_name: .*" --replace_string="domain_name: https://$new_domain$new_path"
# If "Download images locally" option has been enabled in Internal Settings
download_images_enabled=$(ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \
<<< "SELECT value from internal_setting WHERE name='download_images_enabled '" | tail -n 1)
if [ "$download_images_enabled" = "1" ]; then
ynh_print_info --message="Updating images URL; this operation may take a while..."
# Query/replace the domain/path in every entry.content in mysql database
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \
<<< "UPDATE entry SET content = REPLACE(content, '$old_domain$old_path', '$new_domain$new_path');"
fi
# Clear assets cache
ynh_secure_remove --file="$install_dir/var/cache"
mkdir "$install_dir/var/cache"
chown "$app:www-data" "$install_dir/var/cache"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last