1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/weblate_ynh.git synced 2024-10-01 13:35:04 +02:00
weblate_ynh/scripts/change_url
Éric Gaspar cd60686646 cleaning
2024-09-18 20:34:28 +02:00

75 lines
2.7 KiB
Bash

#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping systemd services..."
ynh_systemctl --service=$app --action="stop" --log_path="/var/log/$app/weblate.log" --wait_until="goodbye to uWSGI"
ynh_systemctl --service="$app-celery" --action="stop" --log_path="systemd"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
ynh_config_change_url_nginx
#=================================================
# MODIFY SETTINGS
#=================================================
ynh_script_progression "Modify weblate's config file..."
settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
ynh_backup_if_checksum_is_different "$settings"
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
ynh_replace --match="URL_PREFIX = \"${old_path%/}\"" --replace="URL_PREFIX = \"${new_path%/}\"" --file="$settings"
fi
# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# replace SERVER_EMAIL
ynh_replace --match="noreply@$old_domain" --replace="noreply@$new_domain" --file="$settings"
# replace SITE_DOMAIN
ynh_replace --match="SITE_DOMAIN = \"$old_domain\"" --replace="SITE_DOMAIN = \"$new_domain\"" --file="$settings"
# replace ALLOWED_HOSTS
ynh_replace --match="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace="ALLOWED_HOSTS = \[\"$new_domain\"\]" --file="$settings"
fi
ynh_store_file_checksum "$settings"
#=================================================
# MODIFY UWSGI
#=================================================
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
ynh_backup_if_checksum_is_different "$finaluwsgiini"
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
ynh_replace --match="mount = $old_path=" --replace="mount = $new_path=" --file="$finaluwsgiini"
fi
ynh_store_file_checksum "$finaluwsgiini"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service=$app --action="start" --log_path="/var/log/$app/weblate.log" --wait_until="spawned uWSGI"
ynh_systemctl --service="$app-celery" --action="start" --log_path="/var/log/$app/weblate-celery-celery.log" --wait_until="mingle: all alone"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"