Skip to content

Instantly share code, notes, and snippets.

@tomasinouk
Created March 28, 2018 04:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasinouk/a8033f35778cad51d2d40fdbbcece0b2 to your computer and use it in GitHub Desktop.
Save tomasinouk/a8033f35778cad51d2d40fdbbcece0b2 to your computer and use it in GitHub Desktop.
Reset PoE if ping fails on SmartFlex - PoE unit
# created by Tomas Blaha - Dureco
# script check camera IP via ping every 30s
# if cannot ping it turn Off/On PoE for this camera only
# it does not cycle PoE on second PoE port
CAMERA_PING=192.168.1.22
while true
do
ping -c 1 $CAMERA_PING
PING=$?
if [ $PING = 0 ]; then
# /etc/init.d/ppp stop
echo "Camera online"
logger "Camera online"
else
echo "Camera offline"
logger "Camera offline"
echo "Switching Off POE-0"
logger "Switching Off POE-0"
# change POE ETH0 to disabled
sed -e "s/\(ETH_POE_PSE=\).*/\10/" -i /etc/settings.eth
service eth restart
sleep 3
echo "Switching On POE-0"
logger "Switching On POE-0"
# change POE ETH0 to enabled
sed -e "s/\(ETH_POE_PSE=\).*/\11/" -i /etc/settings.eth
service eth restart
fi
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment