diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..1738931 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,18 @@ # PERSONAL HELPERS #================================================= +_set_BasePathOverride() { + if [[ "$path" == "/" ]]; then + path_or_null=null + else + path_or_null="\"$path\"" + fi + + jq ".BasePathOverride = $path_or_null" "$install_dir/.config/Jackett/ServerConfig.json" \ + > "$install_dir/.config/Jackett/ServerConfig.json.tmp" + mv "$install_dir/.config/Jackett/ServerConfig.json.tmp" "$install_dir/.config/Jackett/ServerConfig.json" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 5d07d15..988ddb3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,9 +28,7 @@ ynh_change_url_nginx_config # Change the path in the NGINX config file if [ "$change_path" -eq 1 ]; then - jq ".BasePathOverride = \"$path\"" "$install_dir/.config/Jackett/ServerConfig.json" \ - > "$install_dir/.config/Jackett/ServerConfig.json.tmp" - mv "$install_dir/.config/Jackett/ServerConfig.json.tmp" "$install_dir/.config/Jackett/ServerConfig.json" + _set_BasePathOverride fi #================================================= diff --git a/scripts/install b/scripts/install index 8c78155..a7f55e4 100755 --- a/scripts/install +++ b/scripts/install @@ -45,9 +45,7 @@ ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" - # Start a systemd service ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd" -jq ".BasePathOverride = \"$path\"" "$install_dir/.config/Jackett/ServerConfig.json" \ - > "$install_dir/.config/Jackett/ServerConfig.json.tmp" -mv "$install_dir/.config/Jackett/ServerConfig.json.tmp" "$install_dir/.config/Jackett/ServerConfig.json" +_set_BasePathOverride #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index c5aabba..6a37e5a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,11 +27,13 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=0 +ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep=".config" chmod -R o-rwx "$install_dir" chmod -R "$app:" "$install_dir" +_set_BasePathOverride + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #=================================================