diff options
author | Erich Eckner <git@eckner.net> | 2022-07-28 11:59:09 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2022-07-28 11:59:09 +0200 |
commit | 207a3e9fc1be53683d2dcc74f1640b446742aff8 (patch) | |
tree | eafd6c4c2641d886c4dadb2c2b1aa14b53c7c426 | |
parent | 84432979a01ae460f317a29b253203432545f249 (diff) | |
download | raspi-lights-out-207a3e9fc1be53683d2dcc74f1640b446742aff8.tar.xz |
update colocation
-rw-r--r-- | lights-out.conf | 2 | ||||
-rw-r--r-- | lights-out.in | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lights-out.conf b/lights-out.conf index 7f6dc9e..250ddb6 100644 --- a/lights-out.conf +++ b/lights-out.conf @@ -1,6 +1,8 @@ #!/hint/bash server='fenster' +colocation_server="${server}" +colocation_key='deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' inputs['power']=7 inputs['hdd']=15 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 |