Skip to content

Instantly share code, notes, and snippets.

@tomasinouk
Created March 28, 2018 04:06
Show Gist options
  • Select an option

  • Save tomasinouk/a8033f35778cad51d2d40fdbbcece0b2 to your computer and use it in GitHub Desktop.

Select an option

Save tomasinouk/a8033f35778cad51d2d40fdbbcece0b2 to your computer and use it in GitHub Desktop.

Revisions

  1. tomasinouk created this gist Mar 28, 2018.
    33 changes: 33 additions & 0 deletions reset_poe_smartflex.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # 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