summary refs log tree commit diff
path: root/img/app/etc/mdev/iface
blob: d8ceda57598c35457c36e73c76945d4070675260 (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
34
35
36
#!/bin/execlineb -P
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2020-2021 Alyssa Ross <hi@alyssa.is>

importas -i INTERFACE INTERFACE

if { test $INTERFACE != lo }

# Our IP is encoded in the NIC-specific portion of the interface's MAC
# address.
backtick -E LOCAL_IP {
  awk -F: "{printf \"100.64.%d.%d\\n\", \"0x\" $5, \"0x\" $6}"
  /sys/class/net/${INTERFACE}/address
}

if { ip address add ${LOCAL_IP}/32 dev $INTERFACE }
if { ip link set $INTERFACE up }
if { ip route add 169.254.0.1 dev $INTERFACE }
if { ip route add default via 169.254.0.1 dev $INTERFACE }

# Try to wait for the network to be up.
# If we time out, well, there's not much we can do, so just carry on.
# In future, it would be better if the network VM notified us about
# network changes.
foreground { printf "Waiting for network… " }
foreground {
  ifte { echo "Connected." } { echo "Timed out." }
  pipeline { seq 10 }
  forstdin _
  if -n {
    redirfd -w 2 /dev/null
    wget -qT 6 -O /dev/null http://ipv4.connman.net/online/status.html
  }
}

s6-rc -u change app