From c4109acdc6a3365c41d814af0036dad8612184c0 Mon Sep 17 00:00:00 2001 From: MonkWho <31880166+MonkWho@users.noreply.github.com> Date: Wed, 6 May 2020 04:07:44 -0700 Subject: [PATCH] Updating missing supplicant files --- bin/pfatt-5268AC.sh | 54 ++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/bin/pfatt-5268AC.sh b/bin/pfatt-5268AC.sh index e886923..a426f0d 100644 --- a/bin/pfatt-5268AC.sh +++ b/bin/pfatt-5268AC.sh @@ -1,31 +1,35 @@ -#!/bin/sh +#!/usr/bin/env sh +# +# CONFIG +# ====== +# +# PING_HOST - IP where ping should check for connectivity +# +# SLEEP - How often to check connectivity in seconds +# + PING_HOST=8.8.8.8 SLEEP=5 -LOG=/var/log/pfatt.log -getTimestamp(){ - echo `date "+%Y-%m-%d %H:%M:%S :: [pfatt-5268AC.sh] ::"` -} +############################################################################### -{ - RG_CONNECTED="/usr/sbin/ngctl show laneapfilter:eapout" +RG_CONNECTED="/usr/sbin/ngctl show laneapfilter:eapout" - echo "$(getTimestamp) Starting 5268AC ping monitor ..." - while - if /sbin/ping -t2 -q -c1 $PING_HOST > /dev/null ; then - if $RG_CONNECTED >/dev/null 2>&1 ; then - echo "$(getTimestamp) Connection to $PING_HOST is up, but EAP is being bridged!" - echo -n "$(getTimestamp) Disconnecting netgraph node ... " - /usr/sbin/ngctl rmhook laneapfilter: eapout && echo "OK!" || echo "ERROR!" - fi - else - if ! $RG_CONNECTED >/dev/null 2>&1 ; then - echo "$(getTimestamp) Connection to $PING_HOST is down, but EAP is not being bridged!" - echo -n "$(getTimestamp) Connecting netgraph node ... " - /usr/sbin/ngctl connect waneapfilter: laneapfilter: eapout eapout && echo "OK!" || echo "ERROR!" - fi +/usr/bin/logger -sit "pfatt-5268AC" "starting 5268AC ping monitor..." +while +if /sbin/ping -t2 -q -c1 $PING_HOST > /dev/null ; then + if $RG_CONNECTED >/dev/null 2>&1 ; then + /usr/bin/logger -sit "pfatt-5268AC" "connection to $PING_HOST is up, but EAP is being bridged!" + /usr/bin/logger -sit "pfatt-5268AC" "removing laneapfilter: eapout netgraph hook..." + /usr/sbin/ngctl rmhook laneapfilter: eapout fi - sleep $SLEEP - do :; done - echo "$(getTimestamp) Stopping 5268AC ping monitor ..." -} >> $LOG \ No newline at end of file +else + if ! $RG_CONNECTED >/dev/null 2>&1 ; then + /usr/bin/logger -sit "pfatt-5268AC" "connection to $PING_HOST is down, but EAP is not being bridged!" + /usr/bin/logger -sit "pfatt-5268AC" "connecting waneapfilter: -> laneapfilter: netgraph nodes..." + /usr/sbin/ngctl connect waneapfilter: laneapfilter: eapout eapout + fi +fi +sleep $SLEEP +do :; done +/usr/bin/logger -sit "pfatt-5268AC" "stopping 5268AC ping monitor ..."