mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-15 03:49:20 +02:00
Update 20-config
This commit is contained in:
@@ -22,10 +22,31 @@ if ! bashio::fs.file_exists '/config/transmission/settings.json'; then
|
|||||||
cp "/defaults/settings.json" "/config/transmission/settings.json"
|
cp "/defaults/settings.json" "/config/transmission/settings.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
################
|
||||||
|
# Alternate UI #
|
||||||
|
################
|
||||||
|
|
||||||
|
if bashio::config.has_value 'customUI'; then
|
||||||
|
### Variables
|
||||||
|
CUSTOMUI=$(bashio::config 'customUI')
|
||||||
|
if [ "$CUSTOMUI" != "flood-for-transmission" ]; then
|
||||||
|
echo "Setting custom UI"
|
||||||
|
mv /flood-for-transmission /a
|
||||||
|
mv /$CUSTOMUI /flood-for-transmission
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
bashio::log.info "UI selected : $CUSTOMUI"
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# CONFIGURATION #
|
# CONFIGURATION #
|
||||||
#################
|
#################
|
||||||
# Variables
|
|
||||||
|
# Repair structure
|
||||||
|
jq . /config/transmission/settings.json | cat > temp.json && mv temp.json /config/transmission/settings.json
|
||||||
|
|
||||||
|
# INCOMPLETE DIR
|
||||||
|
################
|
||||||
|
|
||||||
echo "Creating config"
|
echo "Creating config"
|
||||||
download_dir=$(bashio::config 'download_dir')
|
download_dir=$(bashio::config 'download_dir')
|
||||||
incomplete_dir=$(bashio::config 'incomplete_dir')
|
incomplete_dir=$(bashio::config 'incomplete_dir')
|
||||||
@@ -55,60 +76,43 @@ CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-host-whitelist-enabled\"=false")
|
|||||||
CONFIG=$(bashio::jq "${CONFIG}" ".\"bind-address-ipv4\"=\"0.0.0.0\"")
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"bind-address-ipv4\"=\"0.0.0.0\"")
|
||||||
|
|
||||||
echo "${CONFIG}" > /config/transmission/settings.json
|
echo "${CONFIG}" > /config/transmission/settings.json
|
||||||
|
jq . /config/transmission/settings.json | cat > temp.json && mv temp.json /config/transmission/settings.json
|
||||||
################
|
|
||||||
# Alternate UI #
|
|
||||||
################
|
|
||||||
|
|
||||||
if bashio::config.has_value 'customUI'; then
|
|
||||||
### Variables
|
|
||||||
CUSTOMUI=$(bashio::config 'customUI')
|
|
||||||
if [ "$CUSTOMUI" != "flood-for-transmission" ]; then
|
|
||||||
echo "Setting custom UI"
|
|
||||||
mv /flood-for-transmission /a
|
|
||||||
mv /$CUSTOMUI /flood-for-transmission
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
bashio::log.info "UI selected : $CUSTOMUI"
|
|
||||||
|
|
||||||
|
|
||||||
####################
|
|
||||||
# From linuxserver #
|
|
||||||
####################
|
|
||||||
|
|
||||||
# USER and PASS
|
# USER and PASS
|
||||||
###############
|
###############
|
||||||
|
|
||||||
# Clean lines
|
CONFIG=$(</config/transmission/settings.json)
|
||||||
#sed -i "/rpc-authentication-required/d" /config/transmission/settings.json
|
USER=$(bashio::config 'user')
|
||||||
#sed -i "/rpc-username/d" /config/transmission/settings.json
|
PASS=$(bashio::config 'pass')
|
||||||
#sed -i "/rpc-password/d" /config/transmission/settings.json
|
if bashio::config.has_value 'user'; then
|
||||||
|
BOOLEAN=true
|
||||||
# Set lines
|
bashio::log.info "User & Pass set, authentification will be with user : $USER and pass : $PASS"
|
||||||
#if bashio::config.has_value 'user'; then
|
else
|
||||||
# USER=$(bashio::config 'user')
|
BOOLEAN=false
|
||||||
# PASS=$(bashio::config 'pass')
|
bashio::log.warning "User & Pass not set, no authentification required"
|
||||||
# sed -i "2 i\"rpc-authentication-required\": true," /config/transmission/settings.json
|
fi
|
||||||
# sed -i "2 i\"rpc-username\": \"$USER\"," /config/transmission/settings.json
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-authentication-required\"=${BOOLEAN}") || sed -i "3 i\"rpc-authentication-required\": ${BOOLEAN}," /config/transmission/settings.json
|
||||||
# sed -i "2 i\"rpc-password\": \"$PASS\"," /config/transmission/settings.json
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-username\"=\"${USER}\"") || sed -i "3 i\"rpc-username\": \"$USER\"," /config/transmission/settings.json
|
||||||
# bashio::log.info "User & Pass set, authentification will be with user : $USER and pass : $PASS"
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-username\"=\"${PASS}\"") || sed -i "3 i\"rpc-password\": \"$PASS\"," /config/transmission/settings.json
|
||||||
#else
|
echo "${CONFIG}" > /config/transmission/settings.json
|
||||||
# sed -i "2 i\"rpc-authentication-required\": false," /config/transmission/settings.json
|
jq . /config/transmission/settings.json | cat > temp.json && mv temp.json /config/transmission/settings.json
|
||||||
# bashio::log.warning "User & Pass not set, no authentification required"
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# WHITELIST
|
# WHITELIST
|
||||||
###########
|
###########
|
||||||
|
|
||||||
#sed -i "/whitelist/d" /config/transmission/settings.json
|
CONFIG=$(</config/transmission/settings.json)
|
||||||
#if bashio::config.has_value 'whitelist'; then
|
WHITELIST=$(bashio::config 'whitelist')
|
||||||
# WHITELIST=$(bashio::config 'whitelist')
|
if bashio::config.has_value 'whitelist'; then
|
||||||
# bashio::log.info "Whitelist set, no authentification from IP $WHITELIST"
|
BOOLEAN=true
|
||||||
# sed -i "2 i\"rpc-whitelist-enabled\": true," /config/transmission/settings.json
|
bashio::log.info "Whitelist set, no authentification from IP $WHITELIST"
|
||||||
# sed -i "2 i\"rpc-whitelist\": \"$WHITELIST\"," /config/transmission/settings.json
|
else
|
||||||
#else
|
BOOLEAN=false
|
||||||
# sed -i "2 i\"rpc-whitelist-enabled\": false," /config/transmission/settings.json
|
sed -i "2 i\"rpc-whitelist-enabled\": false," /config/transmission/settings.json
|
||||||
#fi
|
fi
|
||||||
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist-enabled\"=${BOOLEAN}") || sed -i "3 i\"rpc-whitelist-enabled\": ${BOOLEAN}," /config/transmission/settings.json
|
||||||
|
CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist\"=\"$WHITELIST\"") || sed -i "3 i\"rpc-whitelist\": \"$WHITELIST\"," /config/transmission/settings.json
|
||||||
|
echo "${CONFIG}" > /config/transmission/settings.json
|
||||||
|
jq . /config/transmission/settings.json | cat > temp.json && mv temp.json /config/transmission/settings.json
|
||||||
|
|
||||||
#if [ ! -z "$HOST_WHITELIST" ]; then
|
#if [ ! -z "$HOST_WHITELIST" ]; then
|
||||||
# sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": true,' /config/transmission/settings.json
|
# sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": true,' /config/transmission/settings.json
|
||||||
@@ -117,3 +121,5 @@ bashio::log.info "UI selected : $CUSTOMUI"
|
|||||||
# sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": false,' /config/transmission/settings.json
|
# sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": false,' /config/transmission/settings.json
|
||||||
# sed -i "/\"rpc-host-whitelist\"/c\ \"rpc-host-whitelist\": \"$HOST_WHITELIST\"," /config/transmission/settings.json
|
# sed -i "/\"rpc-host-whitelist\"/c\ \"rpc-host-whitelist\": \"$HOST_WHITELIST\"," /config/transmission/settings.json
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
|
echo "${CONFIG}" > /config/transmission/settings.json
|
||||||
|
|||||||
Reference in New Issue
Block a user