Added some sensible curl flags

This commit is contained in:
Shy 2024-08-02 20:47:17 +02:00
parent 1eec99af8e
commit bdde1235dc

12
wled
View file

@ -6,6 +6,8 @@
# Author: Shy # Author: Shy
# License: CC0 # License: CC0
CURL_FLAGS="--silent --show-error --fail --ipv4 --max-filesize 64K"
print_usage() { print_usage() {
echo "Usage: $0 f(nordcenter)|w(ohnzimmer) on|off|1-17|list" echo "Usage: $0 f(nordcenter)|w(ohnzimmer) on|off|1-17|list"
} }
@ -33,17 +35,17 @@ esac
# Parse and execute command argument. # Parse and execute command argument.
case "$2" in case "$2" in
on) 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) 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]) [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) l|list)
echo "Presets on $wled_host:" 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. # Split into lines. One line per preset.
sed --sandbox -n 's/"\([0-9]\{1,2\}\)"/\n"\1"/gp' | \ sed --sandbox -n 's/"\([0-9]\{1,2\}\)"/\n"\1"/gp' | \
# Extract number and name. Append final newline. # Extract number and name. Append final newline.
@ -51,7 +53,7 @@ case "$2" in
exit $? exit $?
;; ;;
dump) dump)
curl -s -4 -w '\n' "http://$wled_host/json" curl $CURL_FLAGS -w '\n' "http://$wled_host/json"
exit 0 exit 0
;; ;;
*) *)