[ -n "$mode" ] || return 0
config_get community "$cfg" CommunityName
[ -n "$community" ] || return 0
- config_get oidrestrict "$cfg" RestrictOID
+
+ config_get_bool oidrestrict "$cfg" RestrictOID 0
config_get oid "$cfg" RestrictedOID
- echo -n "$mode $community default" >> $CONFIGFILE
- [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
- [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+ if [ "$oidrestrict" -eq 1 ]; then
+ [ -n "$oid" ] || return 0
+ echo "$mode $community default $oid" >> $CONFIGFILE
+ else
+ echo "$mode $community default" >> $CONFIGFILE
+ fi
}
snmpd_access_HostName_add() {
[ -n "$mode" ] || return 0
config_get community "$cfg" CommunityName
[ -n "$community" ] || return 0
- config_get oidrestrict "$cfg" RestrictOID
+
+ config_get_bool oidrestrict "$cfg" RestrictOID 0
config_get oid "$cfg" RestrictedOID
- echo -n "$mode $community $hostname" >> $CONFIGFILE
- [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
- [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+ if [ "$oidrestrict" -eq 1 ]; then
+ [ -n "$oid" ] || return 0
+ echo "$mode $community $hostname $oid" >> $CONFIGFILE
+ else
+ echo "$mode $community $hostname" >> $CONFIGFILE
+ fi
}
snmpd_access_HostIP_add() {
[ -n "$mode" ] || return 0
config_get community "$cfg" CommunityName
[ -n "$community" ] || return 0
- config_get oidrestrict "$cfg" RestrictOID
+
+ config_get_bool oidrestrict "$cfg" RestrictOID 0
config_get oid "$cfg" RestrictedOID
- echo -n "$mode $community $host_ip/$ip_mask" >> $CONFIGFILE
- [ "$oidrestrict" == "yes" ] && echo " $oid" >> $CONFIGFILE
- [ "$oidrestrict" == "no" ] && echo "" >> $CONFIGFILE
+ if [ "$oidrestrict" -eq 1 ]; then
+ [ -n "$oid" ] || return 0
+ echo "$mode $community $host_ip/$ip_mask $oid" >> $CONFIGFILE
+ else
+ echo "$mode $community $host_ip/$ip_mask" >> $CONFIGFILE
+ fi
}
snmpd_pass_add() {