From a4eb236e4871a788d639d2ae94197d39876784be Mon Sep 17 00:00:00 2001 From: Peter Ludikovsky Date: Tue, 5 Mar 2019 13:41:04 +0100 Subject: [PATCH] Status-Push auf WebDAV-Share statt lokaler Datei --- spacestatus.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spacestatus.sh b/spacestatus.sh index d4bcb7c..6fd76c3 100755 --- a/spacestatus.sh +++ b/spacestatus.sh @@ -3,10 +3,11 @@ [ ! -z "$DEBUG" ] && set -x #set -eu +STATUS_HTML=/var/tmp/spacestatus.html +STATUS_JSON=/var/tmp/spacestatus.json function write_html { status=$1 - STATUS_HTML=/srv/www/spacestatus.html TEMPLATE_HTML='Status /usr/space: %s

%s

' CLOSED_HTML='Closed darkred Closed' OPEN_HTML='Open brightgreen Open' @@ -21,7 +22,6 @@ function write_html { function write_json { status=$1 - STATUS_JSON=/srv/www/spacestatus.json TEMPLATE_JSON=$( cat /usr/local/etc/spacestatus.json ) CLOSED_JSON='false' OPEN_JSON='true' @@ -48,6 +48,15 @@ function write_json { fi } +function publish { + CURL=/usr/bin/curl + WEBDAV=https://example.com + CREDS='user:pass' + + ${CURL} --user "${CREDS}" -T "${STATUS_HTML}" "${WEBDAV}" + ${CURL} --user "${CREDS}" -T "${STATUS_JSON}" "${WEBDAV}" +} + tmpcount=$(mktemp) exec 3>$tmpcount /usr/sbin/dhcp-lease-list --parsable | awk '{print $4}' | while read ip @@ -63,4 +72,6 @@ leases=$( cat $tmpcount | wc -l ) write_html $leases write_json $leases +publish + rm $tmpcount