From 913f46cf5a710759bc0892d81b02b0ba63689f5c Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 22 Jan 2022 14:35:48 +0000 Subject: [PATCH] Simplify configuration files --- scripts/install | 29 ++++------------------------- scripts/upgrade | 40 +++++----------------------------------- 2 files changed, 9 insertions(+), 60 deletions(-) diff --git a/scripts/install b/scripts/install index a928f1e..d0e2cce 100644 --- a/scripts/install +++ b/scripts/install @@ -160,32 +160,11 @@ fi #================================================= ynh_script_progression --message="Configuring the settings..." --weight=1 -# Set permissions to app files -chown -R $app: $final_path - -# Load services once to generate system.xml -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 -# Port config -ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" -ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" - -# Enable IPv6 -ynh_replace_string --match_string="false" --replace_string="true" --target_file="$config_path/network.xml" - -# BaseUrl config -ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="$config_path/network.xml" - -# Disable Setup Wizard -ynh_replace_string --match_string="false" --replace_string="true" --target_file="$config_path/system.xml" - -# Lower logging verbosity -cp "$config_path/logging.default.json" "$config_path/logging.json" -ynh_replace_string --match_string="\"Default\": \"Information\"" --replace_string="\"Default\": \"Error\"" --target_file="$config_path/logging.json" - -ynh_store_file_checksum --file="$config_path/network.xml" -ynh_store_file_checksum --file="$config_path/system.xml" +ynh_add_config --template="system.xml" --destination="$config_path/system.xml" +ynh_add_config --template="network.xml" --destination="$config_path/network.xml" +ynh_add_config --template="logging.json" --destination="$config_path/logging.json" #================================================= # INSTALL LDAP PLUGIN @@ -194,7 +173,7 @@ ynh_script_progression --message="Installing LDAP plugin..." --weight=2 ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=ldap mkdir -p /var/lib/jellyfin/plugins/configurations/ -ynh_add_config --template="../conf/LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" +ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 74ae232..0bbfc4e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -181,41 +181,11 @@ ynh_system_user_create --username=$app #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_script_progression --message="Setting up configuration files..." --weight=2 -# Check if network.xml exists (introduced in v10.7) -if [ -f "/etc/jellyfin/network.xml" ]; then - ynh_script_progression --message="Configuring the settings..." --weight=1 - - ynh_backup_if_checksum_is_different --file="$config_path/network.xml" - ynh_backup_if_checksum_is_different --file="$config_path/system.xml" - - # Set permissions to app files - chown -R $app: $final_path - - # Load services once to generate network.xml - ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15 - ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 - - # Port config - ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" - ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="$config_path/network.xml" - - # Enable IPv6 - ynh_replace_string --match_string="false" --replace_string="true" --target_file="$config_path/network.xml" - - # BaseUrl config - ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="$config_path/network.xml" - - ynh_store_file_checksum --file="$config_path/network.xml" - ynh_store_file_checksum --file="$config_path/system.xml" -fi - -# Lower logging verbosity -# But first, if missing, copy it from its template -if [ ! -f "$config_path/logging.json" ]; then - cp "$config_path/logging.default.json" "$config_path/logging.json" -fi -ynh_exec_fully_quiet ynh_replace_string --match_string="\"Default\": \"Information\"" --replace_string="\"Default\": \"Error\"" --target_file="$config_path/logging.json" +ynh_add_config --template="system.xml" --destination="$config_path/system.xml" +ynh_add_config --template="network.xml" --destination="$config_path/network.xml" +ynh_add_config --template="logging.json" --destination="$config_path/logging.json" #================================================= # INSTALL LDAP PLUGIN @@ -224,7 +194,7 @@ ynh_script_progression --message="Installing LDAP plugin..." --weight=2 ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=ldap mkdir -p /var/lib/jellyfin/plugins/configurations/ -ynh_add_config --template="../conf/LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" +ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" #================================================= # GENERIC FINALIZATION