{noformat}
. /usr/local/ics/bin/ics_lib.sh
selfkiller -30:TERM -50:KILL & disown -a
lib_init || exit 1
SECONDS=""
LOGFILE="/var/log/event_sh.log"
LOG_LEVEL=ALL
exec 3>>$LOGFILE 4>/dev/null
exec 2>&3
exec 1>&3
if ! selflock 10; then
LOG WARN "reached time limit $$"
exit
fi
if [ $SECONDS -ge 9 ]; then
exit;
fi
SENDER=$1; shift
EVENT=$1; shift
DATA=$@
for VAR in $DATA; do
[[ "$VAR" = *"="* ]] && eval ${VAR%%=*}=\'${VAR#*=}\'
done
LOG INFO "$SENDER $EVENT $DATA"
{
case "$EVENT" in
"balance_negative")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
;;
"balance_positive")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
;;
"login")
LOG INFO "event type: $EVENT $DATA"
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$over_limit" = 0 ] && echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
;;
"logout")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"rate_set")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",Deactivate-Service-Name=\"service$ceil_in\"" | radclient -x $nas_ip:1700 coa redback;
echo "Acct-Session-Id=\"$acct_session_id\",Service-Name=\"service$ceil_in\",Service-Action=\"0\"" | radclient -x $nas_ip:1700 coa redback;
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
;;
"period_closed")
LOG INFO "event type: $EVENT $DATA"
;;
"try_double_login")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"user_data_changed")
LOG INFO "event type: $EVENT $DATA"
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$over_limit" = 0 ] && echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"user_del")
LOG INFO "event type: $EVENT $DATA"
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
*)
:
;;
esac
} >>/var/log/event_err.log
{noformat}
. /usr/local/ics/bin/ics_lib.sh
selfkiller -30:TERM -50:KILL & disown -a
lib_init || exit 1
SECONDS=""
LOGFILE="/var/log/event_sh.log"
LOG_LEVEL=ALL
exec 3>>$LOGFILE 4>/dev/null
exec 2>&3
exec 1>&3
if ! selflock 10; then
LOG WARN "reached time limit $$"
exit
fi
if [ $SECONDS -ge 9 ]; then
exit;
fi
SENDER=$1; shift
EVENT=$1; shift
DATA=$@
for VAR in $DATA; do
[[ "$VAR" = *"="* ]] && eval ${VAR%%=*}=\'${VAR#*=}\'
done
LOG INFO "$SENDER $EVENT $DATA"
{
case "$EVENT" in
"balance_negative")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
;;
"balance_positive")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
;;
"login")
LOG INFO "event type: $EVENT $DATA"
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$over_limit" = 0 ] && echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
;;
"logout")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"rate_set")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\",Deactivate-Service-Name=\"service$ceil_in\"" | radclient -x $nas_ip:1700 coa redback;
echo "Acct-Session-Id=\"$acct_session_id\",Service-Name=\"service$ceil_in\",Service-Action=\"0\"" | radclient -x $nas_ip:1700 coa redback;
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
;;
"period_closed")
LOG INFO "event type: $EVENT $DATA"
;;
"try_double_login")
LOG INFO "event type: $EVENT $DATA"
echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"user_data_changed")
LOG INFO "event type: $EVENT $DATA"
[ "$over_limit" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\",HTTP-Redirect-Profile-Name=\"NOAUTH\",Forward-Policy=\"in:NOAUTH-IPOE\"" | radclient -x $nas_ip:1700 coa redback
[ "$over_limit" = 0 ] && echo "Acct-Session-Id=\"$acct_session_id\",Forward-Policy = \"in:\"" | radclient -x $nas_ip:1700 coa redback
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
"user_del")
LOG INFO "event type: $EVENT $DATA"
[ "$deleted" = 1 ] && echo "Acct-Session-Id=\"$acct_session_id\"" | radclient -x $nas_ip:1700 disconnect redback
;;
*)
:
;;
esac
} >>/var/log/event_err.log
{noformat}