Doorcam

From NURDspace
  • axis dome at frontdoor
  • monitored by the following cron-entry on 'librenms'
    • */15 * * * * /usr/local/bin/ping-door-cam.sh

Deurdomecamera.jpg

/usr/local/bin/ping-door-cam.sh

#! /bin/sh

ping -c 1 -q 10.208.0.22 > /dev/null

if [ $? -ne 0 ] ; then
	/usr/bin/mosquitto_pub -h mqtt.vm.nurd.space -t 'GHBot/to/irc/nurdsbofh/privmsg' -m 'Door camera down?'
	/usr/local/bin/reboot-door-cam
	/usr/bin/mosquitto_pub -h mqtt.vm.nurd.space -t 'GHBot/to/irc/nurdsbofh/privmsg' -m 'Door camera rebooted'
fi

reboot-door-cam

#!/usr/bin/env bash

CMDFILE="$(mktemp)"
chmod 0644 ${CMDFILE}
cat > ${CMDFILE} <<EOF
conf t
int Gi1/0/14
power inline never
EOF
sudo -u rancid clogin -x "${CMDFILE}" poe-sw
rm ${CMDFILE}

sleep 1

CMDFILE="$(mktemp)"
chmod 0644 ${CMDFILE}
cat > ${CMDFILE} <<EOF
conf t
int Gi1/0/14
power inline auto
EOF
sudo -u rancid clogin -x "${CMDFILE}" poe-sw
rm ${CMDFILE}