add metadata files

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2025-05-15 21:20:28 +02:00
commit bf00263bc5
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
9 changed files with 206 additions and 5 deletions

11
files/dnsmasq.service Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=dnsmasq in netns %i
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/run-dnsmasq-in-netns.sh %i
ExecStopPost=/bin/rm -f /run/dnsmasq-%i.pid
[Install]
WantedBy=multi-user.target

21
files/dnsmasq.sh Normal file
View file

@ -0,0 +1,21 @@
#!/bin/bash
set -e
# Expects one argument: netns_bridge (e.g. vpc-00003_br-00002 or vpc1_br0)
arg="$1"
NETNS="${arg%%_*}"
BRIDGE="${arg#*_}"
echo "start dnsmasq ${NETNS} ${BRIDGE}"
exec ip netns exec "${NETNS}" \
dnsmasq \
--no-daemon \
--interface="${BRIDGE}" \
--bind-interfaces \
--pid-file="/run/dnsmasq-$arg.pid" \
--conf-file="/etc/dnsmasq.d/$arg.conf" \
--no-hosts \
--no-resolv \
--log-facility="/var/log/dnsmasq-$arg.log" \
--no-daemon -p0

10
files/metadata.service Normal file
View file

@ -0,0 +1,10 @@
[Unit]
Description=metadata in netns %i
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/run-metadata-in-netns.sh %i
[Install]
WantedBy=multi-user.target

17
files/metadata.sh Normal file
View file

@ -0,0 +1,17 @@
#!/bin/bash
set -e
# Expects one argument: netns_bridge (e.g. vpc-00003_br-00002 or vpc1_br0)
arg="$1"
NETNS="${arg%%_*}"
ip_port="${arg#*_}"
IP="${ip_port%%-*}"
PORT="${ip_port#*-}"
echo "start metadata ${NETNS} "
exec ip netns exec "${NETNS}" \
/usr/bin/metadata \
-file "/opt/metadata/${arg}.json" \
-interface "${IP}" \
-port "${PORT}"