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

78 lines
2.8 KiB
Text
Raw Normal View History

2017-09-21 10:22:34 +02:00
#!/bin/bash
source _common.sh
source /usr/share/yunohost/helpers
2019-05-30 20:51:22 +02:00
#=================================================
# STOP SYSTEMD SERVICE
2017-09-21 10:22:34 +02:00
#=================================================
ynh_script_progression "Stopping systemd services..."
2019-05-30 20:51:22 +02:00
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"
2017-09-21 10:22:34 +02:00
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
2017-09-21 10:22:34 +02:00
ynh_config_change_url_nginx
2024-01-17 14:07:41 +01:00
2017-10-17 15:46:35 +02:00
#=================================================
2020-10-28 12:02:15 +01:00
# SPECIFIC MODIFICATIONS
2017-09-21 10:22:34 +02:00
#=================================================
2020-10-28 16:10:55 +01:00
# MODIFY SETTINGS
2017-09-21 10:22:34 +02:00
#=================================================
ynh_script_progression "Modify weblate's config file..."
2020-10-28 12:02:15 +01:00
2024-01-17 14:07:41 +01:00
settings="$install_dir/venv/lib/$weblate_pypath/site-packages/weblate/settings.py"
ynh_backup_if_checksum_is_different "$settings"
2017-09-21 10:22:34 +02:00
2024-01-18 13:12:54 +01:00
# Change the path in the nginx config file
2017-09-21 10:22:34 +02:00
if [ $change_path -eq 1 ]
then
ynh_replace --match="URL_PREFIX = \"${old_path%/}\"" --replace="URL_PREFIX = \"${new_path%/}\"" --file="$settings"
2017-09-21 10:22:34 +02:00
fi
2024-01-18 13:12:54 +01:00
# Change the domain for nginx
2017-09-21 10:22:34 +02:00
if [ $change_domain -eq 1 ]
then
# replace SERVER_EMAIL
ynh_replace --match="noreply@$old_domain" --replace="noreply@$new_domain" --file="$settings"
2020-10-28 20:39:35 +01:00
# replace SITE_DOMAIN
ynh_replace --match="SITE_DOMAIN = \"$old_domain\"" --replace="SITE_DOMAIN = \"$new_domain\"" --file="$settings"
2017-09-21 10:22:34 +02:00
# replace ALLOWED_HOSTS
ynh_replace --match="ALLOWED_HOSTS = \[\"$old_domain\"\]" --replace="ALLOWED_HOSTS = \[\"$new_domain\"\]" --file="$settings"
2019-05-30 20:51:22 +02:00
fi
ynh_store_file_checksum "$settings"
2019-05-30 20:51:22 +02:00
2020-10-28 16:10:55 +01:00
#=================================================
# MODIFY UWSGI
#=================================================
finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
ynh_backup_if_checksum_is_different "$finaluwsgiini"
2020-10-28 16:10:55 +01:00
2024-01-18 13:12:54 +01:00
# Change the path in the nginx config file
2020-10-28 16:10:55 +01:00
if [ $change_path -eq 1 ]
then
ynh_replace --match="mount = $old_path=" --replace="mount = $new_path=" --file="$finaluwsgiini"
2020-10-28 16:10:55 +01:00
fi
ynh_store_file_checksum "$finaluwsgiini"
2020-10-28 16:10:55 +01:00
2017-09-21 10:22:34 +02:00
#=================================================
2019-05-30 20:51:22 +02:00
# START SYSTEMD SERVICE
2017-09-21 10:22:34 +02:00
#=================================================
ynh_script_progression "Starting $app's systemd service..."
2017-11-21 15:31:11 +01:00
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"
2017-11-21 15:31:11 +01:00
2019-05-30 20:51:22 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2017-11-21 15:31:11 +01:00
ynh_script_progression "Change of URL completed for $app"