You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.2 KiB

#!/bin/bash
echo "=== $0"
set -a
. /etc/vdn/config
set +a
# init slirp connection
#lastEth=$(ifconfig -a | grep eth[0-9] | tail -n 1 | cut -d ':' -f 1)
echo "Wait for network devices."
NB_ETH=`echo $NETWORKS | wc -w`
while :; do
lastEth=$(ip addr | grep : | grep eth[0-9] | cut -d ':' -f 2 | tail -n 1 | tr -d ' ')
[ -n "$lastEth" -a "$lastEth" = eth$NB_ETH ] && break
sleep 1
done
# Set DNS
echo "nameserver 10.0.2.3" > /etc/resolv.conf
# VDN resolver
if [ "$VDN_RESOLV" = 1 ]; then
sed -i -re 's/^(hosts:[[:space:]]+).*$/\1files dns vdn/' /etc/nsswitch.conf
cp /etc/vdn/libnss_vdn.so /lib/x86_64-linux-gnu/libnss_vdn.so.2.0.0
ln -sf libnss_vdn.so.2.0.0 /lib/x86_64-linux-gnu/libnss_vdn.so.2
else
rm -f /lib/x86_64-linux-gnu/libnss_vdn.so.2
fi
# Extra eth (and extra default route)
[ -n "$lastEth" ] && {
ip link set $lastEth down
ip addr flush $lastEth
ip addr add 10.0.2.15/24 dev $lastEth
ip link set $lastEth up
ip route
if [ "$EXTRA_ETH_DEFAULT_ROUTE" = 1 ]; then
# Set default root to host (slirp)
#route add default gw 10.0.2.2 &> /dev/null
ip route add default via 10.0.2.2
fi
ping -c 1 10.0.2.2 &> /dev/null
# Firewall
[ -x /etc/firewall.sh ] && /etc/firewall.sh
}