#!/bin/bash . settings logger -t sublab-updater starting status update insertstatus() { local ec=$? local status if [ $ec -eq 0 ]; then status=online else status=offline fi cp ${WEBPATH}/csstemplate/${status}.${1}.status.css ${WEBPATH}/public/css/${1}.status.css.new mv -f ${WEBPATH}/public/css/${1}.status.css.new ${WEBPATH}/public/css/${1}.status.css return $ec } apistatus() { [ -d "${WEBPATH}/public/api" ] || mkdir -p "${WEBPATH}/public/api" if [ "`cat \"${WEBPATH}/public/api/status\" 2>/dev/null`" != "$1" ]; then wget -q http://127.0.0.1:8042/send -O /dev/null "--post-data=message=sublab status is now: $1" fi echo $1 > "${WEBPATH}/public/api/status" } # Ping Taifun ping -q -c 2 -W 1 172.22.83.5 &> /dev/null insertstatus taifun global_state=$? # Ping Trieste ping -q -c 2 -W 1 172.22.80.4 &> /dev/null insertstatus trieste # Ping Nautilus ping -q -c 2 -W 1 172.22.80.7 &> /dev/null insertstatus nautilus there_state=$? if [ $global_state -eq 0 ]; then if [ $there_state -eq 0 ]; then apistatus open else apistatus closed fi else apistatus unknown fi exit 0