From 4720f636672b143277575d7553bebd9945c4666b Mon Sep 17 00:00:00 2001 From: themodernhakr Date: Tue, 11 Mar 2025 02:01:50 -0500 Subject: [PATCH] Add curl utility Crafty Docker doesn't have access to curl, wget, netcat, etc. This helper script adds the ability to download a file. --- server-properties/helpers/curl.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 server-properties/helpers/curl.sh diff --git a/server-properties/helpers/curl.sh b/server-properties/helpers/curl.sh new file mode 100644 index 0000000..dae85ec --- /dev/null +++ b/server-properties/helpers/curl.sh @@ -0,0 +1,19 @@ +function __curl() { + read -r proto server path <<<"$(printf '%s' "${1//// }")" + if [ "$proto" != "http:" ]; then + printf >&2 "sorry, %s supports only http\n" "${FUNCNAME[0]}" + return 1 + fi + DOC=/${path// //} + HOST=${server//:*} + PORT=${server//*:} + [ "${HOST}" = "${PORT}" ] && PORT=80 + + exec 3<>"/dev/tcp/${HOST}/$PORT" + printf 'GET %s HTTP/1.0\r\nHost: %s\r\n\r\n' "${DOC}" "${HOST}" >&3 + (while read -r line; do + [ "$line" = $'\r' ] && break + done && cat) <&3 + exec 3>&- +} +