Added some sensible curl flags
This commit is contained in:
parent
1eec99af8e
commit
bdde1235dc
1 changed files with 7 additions and 5 deletions
12
wled
12
wled
|
@ -6,6 +6,8 @@
|
|||
# Author: Shy
|
||||
# License: CC0
|
||||
|
||||
CURL_FLAGS="--silent --show-error --fail --ipv4 --max-filesize 64K"
|
||||
|
||||
print_usage() {
|
||||
echo "Usage: $0 f(nordcenter)|w(ohnzimmer) on|off|1-17|list"
|
||||
}
|
||||
|
@ -33,17 +35,17 @@ esac
|
|||
# Parse and execute command argument.
|
||||
case "$2" in
|
||||
on)
|
||||
api_resp=$(curl -s -4 --json '{"on":true}' "http://$wled_host/json")
|
||||
api_resp=$(curl $CURL_FLAGS --json '{"on":true}' "http://$wled_host/json")
|
||||
;;
|
||||
off)
|
||||
api_resp=$(curl -s -4 --json '{"on":false}' "http://$wled_host/json")
|
||||
api_resp=$(curl $CURL_FLAGS --json '{"on":false}' "http://$wled_host/json")
|
||||
;;
|
||||
[1-9]|[1-9][0-7])
|
||||
api_resp=$(curl -s -4 --json "{'on':true,'ps':$2}" "http://$wled_host/json")
|
||||
api_resp=$(curl $CURL_FLAGS --json "{'on':true,'ps':$2}" "http://$wled_host/json")
|
||||
;;
|
||||
l|list)
|
||||
echo "Presets on $wled_host:"
|
||||
curl -s -4 "http://$wled_host/presets.json" | \
|
||||
curl $CURL_FLAGS "http://$wled_host/presets.json" | \
|
||||
# Split into lines. One line per preset.
|
||||
sed --sandbox -n 's/"\([0-9]\{1,2\}\)"/\n"\1"/gp' | \
|
||||
# Extract number and name. Append final newline.
|
||||
|
@ -51,7 +53,7 @@ case "$2" in
|
|||
exit $?
|
||||
;;
|
||||
dump)
|
||||
curl -s -4 -w '\n' "http://$wled_host/json"
|
||||
curl $CURL_FLAGS -w '\n' "http://$wled_host/json"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
|
|
Loading…
Reference in a new issue