mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-31 21:04:05 +02:00
Try improved sed code
https://github.com/alexbelgium/hassio-addons/issues/755
This commit is contained in:
@@ -41,22 +41,13 @@ if bashio::config.has_value 'SavePath'; then
|
|||||||
|
|
||||||
# Set variable
|
# Set variable
|
||||||
DOWNLOADS=$(bashio::config 'SavePath')
|
DOWNLOADS=$(bashio::config 'SavePath')
|
||||||
|
DOWNLOADS=${DOWNLOADS:-/share/downloads} # Default if not set
|
||||||
|
|
||||||
# Replace save path
|
# Replace save path
|
||||||
CURRENTSAVEPATH=$(sed -n '/Downloads\\\SavePath/p' qBittorrent.conf)
|
sed -i -e "/SavePath/d" \
|
||||||
if [[ ${#CURRENTSAVEPATH} -gt 1 ]]; then
|
-e "/\[Preferences\]/a Downloads\\\SavePath=$DOWNLOADS" \
|
||||||
sed -i "s=${CURRENTSAVEPATH#*=}=$DOWNLOADS=g" qBittorrent.conf
|
-e "/\[AutoRun\]/a Downloads\\\DefaultSavePath=$DOWNLOADS" \
|
||||||
else
|
-e "/\[BitTorrent\]/a Downloads\\\DefaultSavePath=$DOWNLOADS" qBittorrent.conf
|
||||||
sed -i "${LINE}a Downloads\\\SavePath=$DOWNLOADS" qBittorrent.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Replace session save path
|
|
||||||
CURRENTSAVEPATH=$(sed -n '/Session\\\DefaultSavePath/p' 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
|
# Info
|
||||||
bashio::log.info "Downloads can be found in $DOWNLOADS"
|
bashio::log.info "Downloads can be found in $DOWNLOADS"
|
||||||
|
|||||||
Reference in New Issue
Block a user