#!/bin/sh
. /usr/lib/webif/webif.sh
# HotSpot add-on module to webif^2 v1.0
# by Liran Tal <liran@enginx.com>
#
# this module is part of the webif^2 interface for the x-wrt.
# thanks to thepeople and nbd for their help to understand the webif
#
# save_snmp port to kamikaze

snmp_public_name=`uci show snmp | grep -i publicname | cut -d"=" -f2`
snmp_public_src=`uci show snmp | grep -i publicsrc | cut -d"=" -f2`
snmp_private_name=`uci show snmp | grep -i privatename | cut -d"=" -f2`
snmp_private_src=`uci show snmp | grep -i privatesrc | cut -d"=" -f2`


cat > /etc/snmp/snmpd.conf <<EOF
com2sec  local      localhost          public
group   localrw        v1            local
group   localrw        v2c           local
group   localrw        usm           local
com2sec  publicro  $snmp_public_src    $snmp_public_name
com2sec  publicrw  $snmp_private_src  $snmp_private_name

group  public   v1   publicro
group  public   v2c  publicro
group  public   usm  publicro
group  private  v1   publicrw
group  private  v2c  publicrw
group  private  usm  publicrw

view  all  included  .1

access  localrw        ""      any       noauth    exact  all    all    all
access  public   ""  any  noauth  exact  all  none  none
access  private  ""  any  noauth  exact  all  all   all
EOF
