This commit is contained in:
Hans Karlinius
2024-12-03 10:46:06 +01:00
parent 80a121b2e7
commit 2a819362cf
6 changed files with 5 additions and 69 deletions

View File

@@ -1,35 +0,0 @@
#!/command/with-contenv bashio
#options=$(bashio::api.supervisor GET "/addons/self/options/config")
#autofind=$(echo $options | jq '. | if .autofind then true else false end')
#autouse=$(echo $options | jq '. | if .autouse then true else false end')
#if $autofind; then
# bashio::log.info "Enable AutoFind"
# /usr/bin/vh_edit_config General AutoFind 1
#else
# bashio::log.info "Disable AutoFind"
# /usr/bin/vh_edit_config General AutoFind 0
#fi
#if $autouse; then
# bashio::log.info "AUTO USE ALL"
# /usr/bin/vhclient -t "AUTO USE ALL"
#else
# bashio::log.info "AUTO USE CLEAR ALL"
# /usr/bin/vhclient -t "AUTO USE CLEAR ALL"
# bashio::log.info "STOP USING ALL LOCAL"
# /usr/bin/vhclient -t "STOP USING ALL LOCAL"
#fi
#if bashio::config.has_value 'clientid'; then
# clientid=($(bashio::config 'clientid'))
# bashio::log.info "Set ClientId to ${clientid}"
# /usr/bin/vh_edit_config General ClientId ${clientid}
#fi
#if bashio::config.has_value 'manualhub'; then
# manualhub=($(bashio::config 'manualhub'))
# bashio::log.info "MANUAL HUB ADD,${manualhub}"
# /usr/bin/vhclient -t "MANUAL HUB ADD,${manualhub}"
#fi

View File

@@ -1,5 +1,8 @@
#!/command/with-contenv bashio
bashio::addon.option 'clientid'
bashio::addon.option 'manualhub'
options=$(bashio::api.supervisor GET "/addons/self/options/config")
autofind=$(echo $options | jq '. | if .autofind then true else false end')
autouse=$(echo $options | jq '. | if .autouse then true else false end')
@@ -31,7 +34,6 @@ else
fi
if [ -n "$manualhub" ]; then
bashio::log.info "Set Settings ManualHubs to ${manualhub}"
/usr/bin/vh_editini Settings ManualHubs ${manualhub}
else

View File

@@ -1,30 +0,0 @@
#!/command/with-contenv bashio
# Changed code from https://gist.github.com/thomedes/6201620#file-ini-sed
file="/config/vhclient.ini"
touch $file
awkconfig_update_value(){
local section="$1"
local key="$2"
local value="$3"
awk -v RS="(^|\n)[:blank:]*\\\\[" -v setFound=0 -v sec="$section"\
-v kv="$key=$value" -v secPat="$section" -v subPat="$key"\
'$1~"^[[:blank:]\[]*" secPat "[:blank:]*\]"{ \
s = sub("[:blank:]*" subPat "[:blank:]*=[^#^;^\n]*", kv);\
$0 = $0 ((0 == s)? "\n" kv "\n" : ""); # adding kv to $0;\
secFound=1;\
}\
$1~"^[^;^#^\n^=]*\]"{\
$0 = "[" $0; # adding the record separator "[" back in\
}\
NF{sub(/\n$/, ""); print $0}\
END{ if (secFound == 0){\
print "[" sec "]";\
print kv;\
}\
}' $file > /tmp/vhclient_config_tmp
}
awkconfig_update_value $1 $2 $3
mv /tmp/vhclient_config_tmp $file