#!/bin/sh

# This script aims to be called by bsnmpd via "extCommand" lines

mdurl() {
    echo "Deprecated"
}

wlurl() {
    echo "Deprecated"
}

defaultidp() {
    echo "Deprecated"
}

__sql() {
    sqlite3 /var/db/univnautes-sp.sqlite3 "$@"
}

idp_federation() {
    __sql "select count(entity_id) from saml_libertyprovider where federation_source!='__local'"
}

idp_local() {
    __sql "select count(entity_id) from saml_libertyprovider where federation_source='__local'"
}

ip_whitelist() {
    cd /usr/local/univnautes/sp
    ctx=$(./manage.py configxml get cpnames  | cut -f1 -d" ")
    ipfw -x $ctx table 42 list | wc -l | tr -dc 0-9
    echo ""
}

cp_sessions() {
    /usr/local/univnautes/sp/cp_get_sessions | wc -l | tr -dc 0-9
    echo ""
}

$*
