Status-Push auf WebDAV-Share statt lokaler Datei
This commit is contained in:
parent
d84ba6a6a4
commit
a4eb236e48
|
@ -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='<!DOCTYPE html><html><head><title>Status /usr/space: %s</title></head><body><p><code style="color: %s">%s</code></p></html>'
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue