From 030f85c21e63d445640c55145aa0c7b148789718 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 21 Feb 2022 11:53:54 +0100 Subject: [PATCH] Allow SavePath for 4.4.1 --- .../91-qbittorrent_configuration.sh | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 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 278232b93..586668926 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh @@ -27,22 +27,27 @@ fi # Default folder # ################## +# Set variable +DOWNLOADS=$(bashio::config 'SavePath') + +# Set configuration if bashio::config.has_value 'SavePath'; then - DOWNLOADS=$(bashio::config 'SavePath') - #sed -i '/DefaultSavePath/d' qBittorrent.conf - #sed -i "$LINE i\Session\\\DefaultSavePath=$DOWNLOADS" qBittorrent.conf + + # Replace save path CURRENTSAVEPATH=$(sed -n '/Downloads\\SavePath/p' qBittorrent.conf) sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf - #sed -i '/SavePath/d' qBittorrent.conf - #sed -i "$LINE i\Downloads\\\SavePath=$DOWNLOADS" qBittorrent.conf - mkdir -p "$DOWNLOADS" || bashio::log.fatal "Error : folder defined in SavePath doesn't exist and can't be created. Check path" - chown -R abc:abc "$DOWNLOADS" || bashio::log.fatal "Error, please check default save folder configuration in addon" + + # Replace session save path + CURRENTSAVEPATH=$(sed -n '/Session\\DefaultSavePath/p' qBittorrent.conf) + sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf + + # Info bashio::log.info "Downloads can be found in $DOWNLOADS" -else - mkdir -p /share/qBittorrent || true - chown -R abc:abc /share/qBittorrent fi +# Create default location +mkdir -p "$DOWNLOADS" || bashio::log.fatal "Error : folder defined in SavePath doesn't exist and can't be created. Check path" +chown -R abc:abc "$DOWNLOADS" || bashio::log.fatal "Error, please check default save folder configuration in addon" ############## # Avoid bugs #