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

103 lines
3.8 KiB
Text
Raw Normal View History

2021-08-05 17:28:35 +02:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
2022-06-21 15:40:04 +02:00
backend_path=$(ynh_app_setting_get --app=$app --key=backend_path)
2021-08-05 17:28:35 +02:00
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
2021-08-08 14:48:10 +02:00
secret=$(ynh_string_random --length=32)
2021-08-08 15:10:05 +02:00
timezone="$(cat /etc/timezone)"
2021-08-05 17:28:35 +02:00
2022-01-17 08:29:28 +01:00
set_motd=$(ynh_app_setting_get --app=$app --key=set_motd)
enable_registration=$(ynh_app_setting_get --app=$app --key=enable_registration)
2022-08-28 10:44:45 +02:00
enable_linksharing=$(ynh_app_setting_get --app=$app --key=enable_linksharing)
enable_taskattachments=$(ynh_app_setting_get --app=$app --key=enable_taskattachments)
enable_taskcomments=$(ynh_app_setting_get --app=$app --key=enable_taskcomments)
2022-08-23 07:35:50 +02:00
enable_emailreminders=$(ynh_app_setting_get --app=$app --key=enable_emailreminders)
2022-08-28 10:44:45 +02:00
enable_userdeletion=$(ynh_app_setting_get --app=$app --key=enable_userdeletion)
maxavatarsize=$(ynh_app_setting_get --app=$app --key=maxavatarsize)
maxitemsperpage=$(ynh_app_setting_get --app=$app --key=maxitemsperpage)
2022-01-17 08:29:28 +01:00
2021-08-05 17:28:35 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
domain="$new_domain"
path="$new_path"
2021-08-08 14:23:34 +02:00
redis_db=$(ynh_redis_get_free_db)
2022-06-21 15:40:04 +02:00
ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml"
2021-08-05 17:28:35 +02:00
2022-06-21 15:40:04 +02:00
chmod 600 "$backend_path/config.yml"
2021-08-05 17:28:35 +02:00
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last