From 4c29936cccf14b82a2f39d166f46979be8e426a7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 13 Mar 2023 10:51:38 +0100 Subject: [PATCH] Replace || with if check https://github.com/alexbelgium/hassio-addons/issues/755 --- .../etc/cont-init.d/91-qbittorrent_configuration.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh b/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh index 1591f462d..514c0cdff 100755 --- a/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh @@ -15,7 +15,7 @@ if [ ! -f "$CONFIG_LOCATION"/qBittorrent.conf ]; then fi cd "$CONFIG_LOCATION"/ || true -LINE=$(sed -n '/Preferences/=' qBittorrent.conf) +LINE=$(sed -n '/Preferences/=' qBittorrent.conf) || bashio::exit.nok "qBittorrent.conf not valid" LINE=$((LINE + 1)) # Remove unused folders @@ -44,13 +44,19 @@ if bashio::config.has_value 'SavePath'; then # Replace save path CURRENTSAVEPATH=$(sed -n '/Downloads\\\SavePath/p' qBittorrent.conf) - sed -i "s=${CURRENTSAVEPATH#*=}=$DOWNLOADS=g" qBittorrent.conf || \ + if [[ ${#CURRENTSAVEPATH} -gt 1 ]]; then + sed -i "s=${CURRENTSAVEPATH#*=}=$DOWNLOADS=g" qBittorrent.conf + else sed -i "${LINE}a Downloads\\\SavePath=$DOWNLOADS" qBittorrent.conf + fi # Replace session save path CURRENTSAVEPATH=$(sed -n '/Session\\\DefaultSavePath/p' qBittorrent.conf) - sed -i "s=${CURRENTSAVEPATH#*=}=$DOWNLOADS=g" qBittorrent.conf || \ + if [[ ${#CURRENTSAVEPATH} -gt 1 ]]; then + sed -i "s=${CURRENTSAVEPATH#*=}=$DOWNLOADS=g" qBittorrent.conf + else sed -i "2a Session\\\DefaultSavePath=$DOWNLOADS" qBittorrent.conf + fi # Info bashio::log.info "Downloads can be found in $DOWNLOADS"