/usr/bin/elastichosts is in elastichosts-utils 20090817-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #!/bin/bash
usage() {
cat >&2 <<EOF
Usage: $0 [ -c | -f FILENAME ] CMD [ARG]...
Options:
-c read input data for API call from stdin
-f FILENAME read input data for API call from FILENAME
-j input and output are in JSON format
-v show full headers sent and received during API call
EOF
exit 1
}
if ! type -t curl >/dev/null; then
echo "This tool requires curl, available from http://curl.haxx.se/" >&2
elif [ ! -n "$EHAUTH" ]; then
echo "Please set EHAUTH=<user uuid>:<secret API key>" >&2
exit 1
fi
DATA=""
EHURI="${EHURI:-https://api.lon-b.elastichosts.com/}"
TYPE=""
VERBOSE=""
while getopts cf:jv OPTION; do
case "$OPTION" in
c)
DATA="-"
;;
f)
if [ -e "$OPTARG" ]; then
case "$OPTARG" in
/*)
DATA="$OPTARG"
;;
*)
DATA="$PWD/$OPTARG"
;;
esac
else
echo "$OPTARG not found" >&2
exit 1
fi
;;
j)
TYPE="application/json"
;;
v)
VERBOSE=-v
;;
*)
usage
;;
esac
done
shift $(($OPTIND - 1))
[ $# -gt 0 ] || usage
EHURI="$EHURI`tr \ / <<< "$*"`"
EHAUTH="user = \"$EHAUTH\""
if [ -z "$DATA" ]; then
curl --data-binary '' -K <(echo "$EHAUTH") -s $VERBOSE \
${TYPE:+-H "Accept: $TYPE"} "$EHURI"
else
cat "$DATA" | curl --data-binary @- -K <(echo "$EHAUTH") -s $VERBOSE \
-H "Content-Type: ${TYPE:-application/octet-stream}" \
${TYPE:+-H "Accept: $TYPE"} -H 'Expect:' "$EHURI"
fi
|