diff --git a/package/gluon-core/files/lib/netifd/proto/gluon_mesh.sh b/package/gluon-core/files/lib/netifd/proto/gluon_mesh.sh index 51412e5f..15ee94c2 100755 --- a/package/gluon-core/files/lib/netifd/proto/gluon_mesh.sh +++ b/package/gluon-core/files/lib/netifd/proto/gluon_mesh.sh @@ -15,8 +15,8 @@ proto_gluon_mesh_setup() { export CONFIG="$1" export IFNAME="$2" - local fixed_mtu transitive - json_get_vars fixed_mtu transitive + local fixed_mtu transitive ipaddr ip6addr + json_get_vars fixed_mtu transitive ipaddr ip6addr export FIXED_MTU="${fixed_mtu:-0}" export TRANSITIVE="${transitive:-0}" @@ -30,18 +30,23 @@ proto_gluon_mesh_setup() { proto_add_data json_add_boolean fixed_mtu "$FIXED_MTU" json_add_boolean transitive "$TRANSITIVE" - if [ ! -n "$ipaddr" ]; then + if [ ! -z "$ipaddr" ]; then json_add_string ipaddr "$ipaddr" - ip addr add "$ipaddr" dev "$IFNAME" fi - if [ ! -n "$ip6addr" ]; then + if [ ! -z "$ip6addr" ]; then json_add_string ip6addr "$ip6addr" - ip addr add "$ip6addr" dev "$IFNAME" fi [ "$IFNAME" != 'br-wan' ] && json_add_string zone 'mesh' proto_close_data proto_send_update "$CONFIG" + if [ ! -z "$ipaddr" ]; then + ip addr add "$ipaddr" dev "$IFNAME" + fi + if [ ! -z "$ip6addr" ]; then + ip addr add "$ip6addr" dev "$IFNAME" + fi + for script in /lib/gluon/core/mesh/post-setup.d/*; do [ ! -x "$script" ] || "$script" done @@ -51,6 +56,16 @@ proto_gluon_mesh_teardown() { export CONFIG="$1" export IFNAME="$2" + local ipaddr ip6addr + json_get_vars ipaddr ip6addr + + if [ ! -z "$ipaddr" ]; then + ip addr del "$ipaddr" dev "$IFNAME" + fi + if [ ! -z "$ip6addr" ]; then + ip addr del "$ip6addr" dev "$IFNAME" + fi + for script in /lib/gluon/core/mesh/teardown.d/*; do [ ! -x "$script" ] || "$script" done