mirror of
https://github.com/YunoHost-Apps/tvheadend_ynh.git
synced 2024-10-01 13:34:50 +02:00
Update change_url script
This commit is contained in:
parent
984fa119b7
commit
24febd0745
1 changed files with 33 additions and 24 deletions
|
@ -24,17 +24,32 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
superuser=$(ynh_app_setting_get --app=$app --key=superuser)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
conf_dir=$(ynh_app_setting_get --app=$app --key=conf_dir)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
stream_port=$(ynh_app_setting_get --app=$app --key=stream_port)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup () {
|
||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
|
@ -63,19 +78,28 @@ ynh_script_progression --message="Updating NGINX web server configuration..." --
|
|||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
# 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
|
||||
# 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
|
||||
# Set global variables for NGINX helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
|
||||
# Update Tvheadend configuration file
|
||||
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
|
||||
if [ "$path_url" = "/" ]
|
||||
then
|
||||
ynh_add_config --template="tvheadend_no_subpath" --destination="/etc/default/tvheadend"
|
||||
else
|
||||
ynh_add_config --template="tvheadend" --destination="/etc/default/tvheadend"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
# Change the domain for NGINX
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
|
@ -85,21 +109,6 @@ then
|
|||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating Tvheadend configuration..." --weight=1
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="/etc/default/tvheadend"
|
||||
cp ../conf/tvheadend /etc/default/tvheadend
|
||||
ynh_replace_string --match_string="__CONF_DIR__" --replace_string="$final_path/.hts/tvheadend" --target_file="/etc/default/tvheadend"
|
||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="/etc/default/tvheadend"
|
||||
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="/etc/default/tvheadend"
|
||||
ynh_replace_string --match_string="__STREAM_PORT__" --replace_string="$stream_port" --target_file="/etc/default/tvheadend"
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/default/tvheadend"
|
||||
ynh_store_file_checksum --file="/etc/default/tvheadend"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
|
Loading…
Add table
Reference in a new issue