Browse Source

Updated so logging of failed remove ip (doesnt exist) error. Not necessary

Joachim M. Giæver 7 years ago
parent
commit
9813fcefc6
2 changed files with 26 additions and 9 deletions
  1. 24 5
      aiop/aiop-func
  2. 2 4
      aiop/aiop-openvpn

+ 24 - 5
aiop/aiop-func

@@ -11,8 +11,11 @@ cmd_log () {
 }
 
 cmd_run () {
-    CMD=`${2}`
+    CMD=`${2} 2> /dev/null`
     ERRCODE=$?
+    if [ $# -eq 3 ] && [ "${3}" = "-nolog" ]; then
+        return ${ERRCODE}
+    fi
     cmd_log ${ERRCODE} "${1}" "${ERR}: ${2}, ${CMD}"
     return ${ERRCODE}
 }
@@ -25,11 +28,23 @@ iptable () {
         iptable "${IFACE}" "D" ${@}
     fi
     if [ $# -eq 1 ]; then
-        cmd_run "iptable" "iptables -t nat -${OPT} POSTROUTING -s ${1} -o ${IFACE} -j MASQUERADE"
+        if [ "${OPT}" = "D" ]; then
+            cmd_run "iptable" "iptables -t nat -${OPT} POSTROUTING -s ${1} -o ${IFACE} -j MASQUERADE" "-nolog"
+        else
+            cmd_run "iptable" "iptables -t nat -${OPT} POSTROUTING -s ${1} -o ${IFACE} -j MASQUERADE"
+        fi
     elif [ $# -eq 2 ]; then
-        cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -m state --state NEW -j ${2}"
+        if [ "${OPT}" = "D" ]; then
+            cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -m state --state NEW -j ${2}" "-nolog"
+        else
+            cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -m state --state NEW -j ${2}"
+        fi
     elif [ $# -eq 3 ]; then
-        cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -o ${3} -j ${2}"
+        if [ "${OPT}" = "D" ]; then
+            cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -o ${3} -j ${2}" "-nolog"
+        else
+            cmd_run "iptable" "iptables -${OPT} ${1} -i ${IFACE} -o ${3} -j ${2}"
+        fi
     else
         cmd_log 0 "iptable" "Unknown argument length ${#} (${@})."
     fi
@@ -39,5 +54,9 @@ ebtable () {
     if [ "${2}" = "I" ]; then
         ebtable "${1}" "D" "${3}"
     fi
-    cmd_run "ebtable" "ebtables -t broute -${2} BROUTING -p ${3} -i ${1} -j DROP"
+    if [ "${2}" = "D" ]; then
+        cmd_run "ebtable" "ebtables -t broute -${2} BROUTING -p ${3} -i ${1} -j DROP" "-nolog"
+    else
+        cmd_run "ebtable" "ebtables -t broute -${2} BROUTING -p ${3} -i ${1} -j DROP"
+    fi
 }

+ 2 - 4
aiop/aiop-openvpn

@@ -25,9 +25,7 @@ route_vpn () {
     fi
 
     ip route show table main | grep -Ev ^default | while read ROUTE; do
-        if [ `ip route show table "${RTABLE}" | grep -ice "${ROUTE}"` -eq 0 ]; then
-            cmd_run "ip-route" "ip route add table ${RTABLE} ${ROUTE}"
-        fi
+        cmd_run "ip-route" "ip route add table ${RTABLE} ${ROUTE}" "-nolog"
     done
     
     cmd_run "ip-route" "ip route add default dev ${IFACE_TUN} table ${RTABLE}"
@@ -56,7 +54,7 @@ unroute_vpn () {
         CIDR="${3}"
     fi
 
-    cmd_run "ip-route" "ip route flush table ${RTABLE}"
+    cmd_run "ip-route" "ip route flush table ${RTABLE}" "-nolog"
 
     iptable "${IFACE}" "D" "FORWARD" "ACCEPT" "${IFACE_TUN}"
     iptable "${IFACE_TUN}" "D" "${IFACE_NWRK_ADDR}/${CIDR}"