summaryrefslogtreecommitdiffstats
path: root/core/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-early_network_triggers
blob: 64ea853e8979a4c2f5cf8b547e315e4070a1b623 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/ash

# This script will trigger several network targets if
# applicable at an early point.
# This happens if dhcp/network setup was successful in stage31

# Main interface
BRIDGE="br0"

if [ ! -e "/sys/class/net/${BRIDGE}/operstate" -o "x$(cat "/sys/class/net/${BRIDGE}/operstate")" == "xup" ] && [ -e "/opt/openslx/uniontmp/etc/hostname" -o -e "/etc/resolv.conf" ]; then
	echo "Triggering network.target"
	touch "/run/network/network-ready"
	systemctl start network.target &
fi

if [ -s "/etc/resolv.conf" ] && grep -q "^nameserver" "/etc/resolv.conf"; then
	echo "Triggering network-dns.target"
	touch "/run/network/dns-ready"
	systemctl start network-dns.target &
fi

if route -n | grep -q -E '^0\.0\.0\.0.*U.*G'; then
	echo "Triggering network-gateway.target"
	touch "/run/network/gateway-ready"
	systemctl start network-gateway.target &
fi

# In case we have multiple NICs per subnet, don't send arp
# replies on all NICs
echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter

exit 0