more scripts and configs

This commit is contained in:
2024-07-14 13:52:00 +03:00
parent 99263d1882
commit 0b8df0f42a
9 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#!/bin/sh
LOG=/opt/tmp/ndm-debug.log
echo "=====================" >> $LOG
echo "$1\n\n$change\n\n$id" >> $LOG
echo "${id}-${change}-${connected}-${link}-${up}" >> $LOG
#!/bin/sh
[ "$1" == "hook" ] || exit 0
#[ "$change" == "link" ] || exit 0
[ "$id" == "Wireguard0" ] || exit 0
IF_NAME=nwg0
IF_GW4=$(ip -4 addr show "$IF_NAME" | grep -Po "(?<=inet ).*(?=/)")
case ${id}-${change}-${connected}-${link}-${up} in
${id}-config-no-down-down)
ip -4 rule del fwmark 0xd1000 lookup 1001 priority 1778 2>/dev/null
ip -4 route flush table 1001
;;
${id}-connected-yes-up-up)
ip -4 route add table 1001 default via "$IF_GW4" dev "$IF_NAME" 2>/dev/null
ip -4 route show table main |grep -Ev ^default |while read ROUTE; do ip -4 route add table 1001 $ROUTE 2>/dev/null; done
ip -4 rule add fwmark 0xd1000 lookup 1001 priority 1778 2>/dev/null
ip -4 route flush cache
;;
esac
exit 0