aboutsummaryrefslogtreecommitdiffstats
path: root/examples/scripts/init.sh
blob: d9bfaf25f49bf3cbfd1619b8031c61803824d5bb (plain)
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
37
38
39
40
41
42
43
44
45
#!/usr/bin/sh

temp=${ID##*(0)}
i=2
while [ $i -ge 0 ]
do
  # shellcheck disable=SC2034  # `address` variable used in eval
  address[$i]=$((temp%256))
  temp=$((temp/256))
  i=$((i-1))
done

IFS='.' command eval 'nat="10.${address[*]}/8"'

mkdir -p "${DIRECTORY}"/etc/systemd/resolved.conf.d
cat <<- END > "${DIRECTORY}"/etc/systemd/resolved.conf.d/llmnr.conf
    [Resolve]
    LLMNR=true
END

cat <<- END > "${DIRECTORY}"/etc/systemd/network/00-host0.network
    [Match]
    Virtualization=container
    Name=host0

    [Network]
    LinkLocalAddressing=0
    ConfigureWithoutCarrier=1
    Address=192.168.0.$((10+INSTANCE))/24
END

# shellcheck disable=SC2154  # `nat` variable assigned in eval
cat <<- END > "${DIRECTORY}"/etc/systemd/network/00-host9.network
    [Match]
    Name=host9

    [Network]
    LinkLocalAddressing=0
    ConfigureWithoutCarrier=1
    Address=$nat
    Gateway=10.255.255.254
    LLMNR=false
    DNS=146.163.252.126
    DNS=146.163.252.127
END