diff options
Diffstat (limited to 'lights-out.in')
-rw-r--r-- | lights-out.in | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lights-out.in b/lights-out.in index 2071487..ebed1eb 100644 --- a/lights-out.in +++ b/lights-out.in @@ -10,6 +10,7 @@ display_help() { >&2 printf ' lights-out name: print the name of the server\n' >&2 printf ' lights-out push $output $time: simulate push on $output for $time seconds\n' >&2 printf ' lights-out turn on: turn on machine if not yet running\n' + >&2 printf ' lights-out update colocation: update server state on colocation\n' } check_argument_count() { @@ -122,6 +123,28 @@ case "$1" in check_argument_count 1 "$@" "$0" 'turn' 'on' || exit $? ;; + 'update') + if [ $# -ne 2 ] \ + || [ "x$2" != 'xcolocation' ]; then + >&2 printf 'unknown command "%s"\n\n' "$*" + display_help + exit 1 + fi + power=$( + "$0" get power + ) || exit $? + if [ ${power} -eq 1 ] \ + && ping -c1 "${server}" 2>&1 >/dev/null; then + ping=1 + else + ping=0 + fi + curl -Ss "https://colocation.eckner.net/update.php?machine=${colocation_server}&key=${colocation_key}&power=${power}&ping=${ping}" || exit $? + ;; + 'update colocation') + check_argument_count 1 "$@" + "$0" 'update' 'colocation' || exit $? + ;; *) >&2 printf 'unknown command "%s"\n\n' "$1" display_help |