Allow MAC configuration through file

This commit is contained in:
Kroese 2023-04-10 21:00:56 +02:00
parent cd1cb3095c
commit 70138041b7

View File

@ -2,8 +2,8 @@
set -eu set -eu
: ${VM_NET_TAP:=''} : ${VM_NET_TAP:=''}
: ${VM_NET_MAC:=''}
: ${VM_NET_IP:='20.20.20.21'} : ${VM_NET_IP:='20.20.20.21'}
: ${VM_NET_MAC:='00:11:32:2C:A7:85'}
: ${DNSMASQ:='/usr/sbin/dnsmasq'} : ${DNSMASQ:='/usr/sbin/dnsmasq'}
: ${DNSMASQ_OPTS:=''} : ${DNSMASQ_OPTS:=''}
@ -61,6 +61,16 @@ if [ ! -c /dev/net/tun ]; then
fi fi
[ ! -c /dev/net/tun ] && echo "Error: TUN network interface not available..." && exit 85 [ ! -c /dev/net/tun ] && echo "Error: TUN network interface not available..." && exit 85
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 86
#If environment variabele not set fall back to file
if [ -z "$VM_NET_MAC" ]; then
FILE="${IMG}/guest.mac"
if [ ! -f "$FILE" ]; then
echo "00:11:32:2C:A7:85" > "$FILE"
fi
VM_NET_MAC=$(cat "${FILE}")
fi
update-alternatives --set iptables /usr/sbin/iptables-legacy > /dev/null update-alternatives --set iptables /usr/sbin/iptables-legacy > /dev/null
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null