-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathentrypoint.sh
executable file
·45 lines (39 loc) · 1.42 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
if [ -n "$useENV" ]; then
echo "Generate config from env."
# Convert $blockList to json array
tmpBlockList='[]'
tmpIPBlockList='[]'
if [ -n "$blockList" ]; then
tmpBlockList=$(echo $blockList | jq '.')
fi
if [ -n "$ipBlockList" ]; then
tmpIPBlockList=$(echo $ipBlockList | jq '.')
fi
envKVPair=$(jq -n 'env|to_entries[]')
# Keep username and password string
# Keep blockList json array
# Convert "true" to true, "false" to false, digital string to number
configKVPair=$(echo $envKVPair | jq --argjson tmpBlockList "$tmpBlockList" --argjson tmpIPBlockList "$tmpIPBlockList" '{
(.key): (
if (.key|ascii_downcase) == "clientusername" or (.key|ascii_downcase) == "clientpassword" then .value
elif (.key|ascii_downcase) == "blocklist" then $tmpBlockList
elif (.key|ascii_downcase) == "ipblocklist" then $tmpIPBlockList
else .value|(
if . == "true" then true
elif . == "false" then false
else (tonumber? // .)
end)
end
)
}')
(echo $configKVPair | jq -s add) > config_additional.json
fi
commandArgStr=''
if [ -n "$configPath" ]; then
commandArgStr="-c $configPath"
fi
if [ -n "$additionalConfigPath" ]; then
commandArgStr="$commandArgStr -ca $additionalConfigPath"
fi
exec ./qBittorrent-ClientBlocker $commandArgStr