diff --git a/network.sh b/network.sh index 2f64031..599f1f1 100644 --- a/network.sh +++ b/network.sh @@ -2,8 +2,8 @@ set -eu : ${VM_NET_TAP:=''} +: ${VM_NET_MAC:=''} : ${VM_NET_IP:='20.20.20.21'} -: ${VM_NET_MAC:='00:11:32:2C:A7:85'} : ${DNSMASQ:='/usr/sbin/dnsmasq'} : ${DNSMASQ_OPTS:=''} @@ -61,6 +61,16 @@ if [ ! -c /dev/net/tun ]; then fi [ ! -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 ip6tables /usr/sbin/ip6tables-legacy > /dev/null