homelab/packer/files/archlinux/root/usr/local/bin/hcloud-network

30 lines
533 B
Plaintext
Raw Normal View History

2024-01-28 08:31:39 +00:00
#!/bin/bash
readonly f=/etc/hcloud-metadata.json
cat <<EOF
[Match]
MACAddress=$(jq -r '.network.mac_address' "$f")
[Network]
Address=$(jq -r '.network.ipv6_address' "$f")/64
Gateway=$(jq -r '.network.ipv4_gateway' "$f")
Gateway=$(jq -r '.network.ipv6_gateway' "$f")
NTP=ntp1.hetzner.de
NTP=ntp2.hetzner.com
NTP=ntp3.hetzner.net
EOF
for nameserver in $(jq -r '.network.nameservers|join(" ")' "$f"); do
echo "DNS=${nameserver}"
done
cat <<EOF
[Address]
Address=$(jq -r '.network.ipv4_address' "$f")/32
Peer=172.31.1.1/32
EOF