net-snmp: add config options
authorfeckert <redacted>
Thu, 6 Aug 2015 10:01:02 +0000 (12:01 +0200)
committerfeckert <redacted>
Thu, 6 Aug 2015 10:01:02 +0000 (12:01 +0200)
- trap_hostname
- trap_ip
- access_default
- access_HostName
- access_HostIP

Signed-off-by: Florian Eckert <redacted>
Signed-off-by: Helge Mader <redacted>
net/net-snmp/files/snmpd.init

index 3dd8c41dc2f836a7312c8f3de09077c6c3386c76..b3054855e72b6dc699f947e0a1b849edfa40cbba 100644 (file)
@@ -99,6 +99,60 @@ snmpd_access_add() {
        echo "access $group $context $version $level $prefix $read $write $notify" >> $CONFIGFILE
 }
 
+snmpd_trap_hostname_add() {
+       local cfg="$1"
+       config_get hostname "$cfg" HostName
+       config_get port "$cfg" Port
+       config_get community "$cfg" Community
+       config_get type "$cfg" Type
+       echo "$type $hostname $community $port" >> $CONFIGFILE
+}
+
+snmpd_trap_ip_add() {
+       local cfg="$1"
+       config_get host_ip "$cfg" HostIP
+       config_get port "$cfg" Port
+       config_get community "$cfg" Community
+       config_get type "$cfg" Type
+       echo "$type $host_ip $community $port" >> $CONFIGFILE
+}
+
+snmpd_access_default_add() {
+       local cfg="$1"
+       config_get mode "$cfg" Mode
+       config_get community "$cfg" CommunityName
+       config_get oidrestrict "$cfg" RestrictOID
+       config_get oid "$cfg" RestrictedOID
+       echo -n "$mode $community default" >> $CONFIGFILE
+       [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
+       [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+}
+
+snmpd_access_HostName_add() {
+       local cfg="$1"
+       config_get hostname "$cfg" HostName
+       config_get mode "$cfg" Mode
+       config_get community "$cfg" CommunityName
+       config_get oidrestrict "$cfg" RestrictOID
+       config_get oid "$cfg" RestrictedOID
+       echo -n "$mode $community $hostname" >> $CONFIGFILE
+       [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
+       [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+}
+
+snmpd_access_HostIP_add() {
+       local cfg="$1"
+       config_get host_ip "$cfg" HostIP
+       config_get ip_mask "$cfg" IPMask
+       config_get mode "$cfg" Mode
+       config_get community "$cfg" CommunityName
+       config_get oidrestrict "$cfg" RestrictOID
+       config_get oid "$cfg" RestrictedOID
+       echo -n "$mode $community $host_ip/$ip_mask" >> $CONFIGFILE
+       [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
+       [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+}
+
 snmpd_pass_add() {
        local cfg="$1"
        local pass='pass'
@@ -151,6 +205,11 @@ start_service() {
        config_foreach snmpd_group_add group
        config_foreach snmpd_view_add view
        config_foreach snmpd_access_add access
+       config_foreach snmpd_trap_hostname_add trap_HostName
+       config_foreach snmpd_trap_ip_add trap_HostIP
+       config_foreach snmpd_access_default_add access_default
+       config_foreach snmpd_access_HostName_add access_HostName
+       config_foreach snmpd_access_HostIP_add access_HostIP
        config_foreach snmpd_pass_add pass
        config_foreach snmpd_exec_add exec
        config_foreach snmpd_disk_add disk
git clone https://git.99rst.org/PROJECT