Doorcam: Difference between revisions

From NURDspace
(Created page with "* axis dome at frontdoor * monitored by the following cron-entry on 'librenms' ** */15 * * * * /usr/local/bin/ping-door-cam.sh ==== /usr/local/bin/ping-door-cam.sh ==== <nowiki>#! /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'...")
 
No edit summary
 
Line 2: Line 2:
* monitored by the following cron-entry on 'librenms'
* monitored by the following cron-entry on 'librenms'
** */15 * * * *    /usr/local/bin/ping-door-cam.sh
** */15 * * * *    /usr/local/bin/ping-door-cam.sh
[[File:Deurdomecamera.jpg|800px]]


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

Latest revision as of 17:29, 4 October 2024

  • 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}