feat: IPv6 support (#211)

This commit is contained in:
Kroese 2025-03-18 03:56:08 +01:00 committed by GitHub
parent f15feef69b
commit 66b70a8fe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 200 additions and 79 deletions

View file

@ -10,9 +10,12 @@ ARG DEBCONF_NONINTERACTIVE_SEEN="true"
RUN set -eu && \ RUN set -eu && \
apt-get update && \ apt-get update && \
apt-get --no-install-recommends -y install \ apt-get --no-install-recommends -y install \
bc \
jq \
tini \ tini \
wget \ wget \
7zip \ 7zip \
curl \
nginx \ nginx \
procps \ procps \
seabios \ seabios \
@ -56,8 +59,8 @@ ADD --chmod=744 https://raw.githubusercontent.com/qemus/qemu/master/web/conf/ngi
VOLUME /storage VOLUME /storage
EXPOSE 22 80 5900 EXPOSE 22 80 5900
ENV CPU_CORES="1" ENV CPU_CORES="2"
ENV RAM_SIZE="1G" ENV RAM_SIZE="2G"
ENV DISK_SIZE="16G" ENV DISK_SIZE="16G"
ENV BOOT="http://example.com/image.iso" ENV BOOT="http://example.com/image.iso"

View file

@ -74,7 +74,7 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu-arm/refs/heads/mas
- Set the `BOOT` variable to the [operating system](#how-do-i-select-the-operating-system) you want to install. - Set the `BOOT` variable to the [operating system](#how-do-i-select-the-operating-system) you want to install.
- Start the container and connect to [port 8006](http://localhost:8006) using your web browser. - Start the container and connect to [port 8006](http://127.0.0.1:8006/) using your web browser.
- You will see the screen and can now install the OS of your choice using your keyboard and mouse. - You will see the screen and can now install the OS of your choice using your keyboard and mouse.
@ -94,12 +94,14 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu-arm/refs/heads/mas
|---|---|---| |---|---|---|
| `alma` | Alma Linux | 1.7 GB | | `alma` | Alma Linux | 1.7 GB |
| `alpine` | Alpine Linux | 60 MB | | `alpine` | Alpine Linux | 60 MB |
| `centos` | CentOS Stream | 6.4 GB | | `cachy` | CachyOS | 2.6 GB |
| `centos` | CentOS | 6.4 GB |
| `debian` | Debian | 3.7 GB | | `debian` | Debian | 3.7 GB |
| `fedora` | Fedora | 2.9 GB | | `fedora` | Fedora | 2.9 GB |
| `gentoo` | Gentoo | 1.3 GB | | `gentoo` | Gentoo | 1.3 GB |
| `kali` | Kali Linux | 3.4 GB | | `kali` | Kali Linux | 3.4 GB |
| `nixos` | NixOS | 2.4 GB | | `nixos` | NixOS | 2.4 GB |
| `suse` | OpenSUSE | 1.0 GB |
| `oracle` | Oracle Linux | 1.0 GB | | `oracle` | Oracle Linux | 1.0 GB |
| `rocky` | Rocky Linux | 1.9 GB | | `rocky` | Rocky Linux | 1.9 GB |
| `ubuntu` | Ubuntu Desktop | 3.3 GB | | `ubuntu` | Ubuntu Desktop | 3.3 GB |
@ -163,13 +165,13 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu-arm/refs/heads/mas
### How do I change the amount of CPU or RAM? ### How do I change the amount of CPU or RAM?
By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM. By default, the container will be allowed to use a maximum of 2 CPU cores and 2 GB of RAM.
If you want to adjust this, you can specify the desired amount using the following environment variables: If you want to adjust this, you can specify the desired amount using the following environment variables:
```yaml ```yaml
environment: environment:
RAM_SIZE: "4G" RAM_SIZE: "8G"
CPU_CORES: "4" CPU_CORES: "4"
``` ```

View file

@ -1,122 +1,216 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -Eeuo pipefail set -Eeuo pipefail
pipe() {
local code="99"
msg="Failed to connect to $1, reason:"
curl --disable --silent --max-time 10 --fail --location "${1}" || {
code="$?"
}
case "${code,,}" in
"6" ) error "$msg could not resolve host!" ;;
"7" ) error "$msg no internet connection available!" ;;
"28" ) error "$msg connection timed out!" ;;
"99" ) return 0 ;;
*) error "$msg $code" ;;
esac
return 1
}
getURL() { getURL() {
local id="${1/ /}" local id="${1/ /}"
local ret="$2" local ret="$2"
local url="" local url=""
local arm= local arm=""
local name="" local name=""
local body=""
local version=""
case "${id,,}" in case "${id,,}" in
"alma" | "almalinux" | "alma-linux" ) "alma" | "almalinux" | "alma-linux" )
name="AlmaLinux" name="AlmaLinux"
url="https://repo.almalinux.org/almalinux/9/live/x86_64/AlmaLinux-9.5-x86_64-Live-GNOME.iso" if [[ "$ret" == "url" ]]; then
arm="https://repo.almalinux.org/almalinux/9/live/aarch64/AlmaLinux-9.5-aarch64-Live-GNOME.iso" ;; url="https://repo.almalinux.org/almalinux/9/live/x86_64/AlmaLinux-9-latest-x86_64-Live-GNOME.iso"
arm="https://repo.almalinux.org/almalinux/9/live/aarch64/AlmaLinux-9-latest-aarch64-Live-GNOME.iso"
fi ;;
"alpine" | "alpinelinux" | "alpine-linux" ) "alpine" | "alpinelinux" | "alpine-linux" )
name="Alpine Linux" name="Alpine Linux"
url="https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso" if [[ "$ret" == "url" ]]; then
arm="https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/aarch64/alpine-virt-3.19.1-aarch64.iso" ;; body=$(pipe "https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/latest-releases.yaml") || exit 65
version=$(echo "$body" | awk '/"Xen"/{found=0} {if(found) print} /"Virtual"/{found=1}' | grep 'version:' | awk '{print $2}')
url="https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/alpine-virt-$version-x86_64.iso"
arm="https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/alpine-virt-$version-aarch64.iso"
fi ;;
"arch" | "archlinux" | "arch-linux" ) "arch" | "archlinux" | "arch-linux" )
name="Arch Linux" name="Arch Linux"
url="https://geo.mirror.pkgbuild.com/iso/2025.03.01/archlinux-x86_64.iso" ;; if [[ "$ret" == "url" ]]; then
url="https://geo.mirror.pkgbuild.com/iso/latest/archlinux-x86_64.iso"
fi ;;
"cachy" | "cachyos" ) "cachy" | "cachyos" )
name="CachyOS" name="CachyOS"
url="https://cdn77.cachyos.org/ISO/desktop/250202/cachyos-desktop-linux-250202.iso" ;; if [[ "$ret" == "url" ]]; then
body=$(pipe "https://cachyos.org/download/") || exit 65
url=$(echo "$body" | tr '&' '\n' | grep "ISO/desktop" | grep -v 'iso.sha' | grep -v 'iso.sig' | cut -d';' -f2)
arm=$(echo "$body" | tr '&' '\n' | grep "ISO/handheld" | grep -v 'iso.sha' | grep -v 'iso.sig' | cut -d';' -f2)
fi ;;
"centos" | "centosstream" | "centos-stream" ) "centos" | "centosstream" | "centos-stream" )
name="CentOS Stream" name="CentOS Stream"
url="https://mirrors.xtom.de/centos-stream/10-stream/BaseOS/x86_64/iso/CentOS-Stream-10-latest-x86_64-dvd1.iso" if [[ "$ret" == "url" ]]; then
arm="https://mirrors.xtom.de/centos-stream/10-stream/BaseOS/aarch64/iso/CentOS-Stream-10-latest-aarch64-dvd1.iso" ;; body=$(pipe "https://linuxsoft.cern.ch/centos-stream/") || exit 65
version=$(echo "$body" | grep "\-stream" | cut -d'"' -f 6 | cut -d'-' -f 1 | head -n 1)
url="https://mirrors.xtom.de/centos-stream/$version-stream/BaseOS/x86_64/iso/CentOS-Stream-$version-latest-x86_64-dvd1.iso"
arm="https://mirrors.xtom.de/centos-stream/$version-stream/BaseOS/aarch64/iso/CentOS-Stream-$version-latest-aarch64-dvd1.iso"
fi ;;
"debian" ) "debian" )
name="Debian" name="Debian"
url="https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-12.9.0-amd64-gnome.iso" if [[ "$ret" == "url" ]]; then
arm="https://cdimage.debian.org/debian-cd/current/arm64/iso-dvd/debian-12.9.0-arm64-DVD-1.iso" ;; body=$(pipe "https://cdimage.debian.org/debian-cd/") || exit 65
"endeavour" | "endeavouros" ) version=$(echo "$body" | grep '\.[0-9]/' | cut -d'>' -f 9 | cut -d'/' -f 1)
name="EndeavourOS" url="https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-$version-amd64-standard.iso"
url="https://mirrors.gigenet.com/endeavouros/iso/EndeavourOS_Mercury-2025.02.08.iso" ;; arm="https://cdimage.debian.org/debian-cd/current/arm64/iso-dvd/debian-$version-arm64-DVD-1.iso"
fi ;;
"fedora" | "fedoralinux" | "fedora-linux" ) "fedora" | "fedoralinux" | "fedora-linux" )
name="Fedora Linux" name="Fedora Linux"
url="https://download.fedoraproject.org/pub/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-41-1.4.iso" if [[ "$ret" == "url" ]]; then
arm="https://eu.edge.kernel.org/fedora/releases/41/Workstation/aarch64/images/Fedora-Workstation-41-1.4.aarch64.raw.xz" ;; body=$(pipe "https://getfedora.org/releases.json") || exit 65
version=$(echo "$body" | jq -r 'map(.version) | unique | .[]' | sed 's/ /_/g' | sort -r | head -n 1)
url=$(echo "$body" | jq -r "map(select(.arch==\"x86_64\" and .version==\"${version}\" and .variant==\"Workstation\" and .subvariant==\"Workstation\" )) | .[].link")
arm=$(echo "$body" | jq -r "map(select(.arch==\"aarch64\" and .version==\"${version}\" and .variant==\"Workstation\" and .subvariant==\"Workstation\" )) | .[].link")
fi ;;
"gentoo" | "gentoolinux" | "gentoo-linux" ) "gentoo" | "gentoolinux" | "gentoo-linux" )
name="Gentoo Linux" name="Gentoo Linux"
url="https://distfiles.gentoo.org/releases/amd64/autobuilds/20250309T170330Z/livegui-amd64-20250309T170330Z.iso" if [[ "$ret" == "url" ]]; then
arm="https://distfiles.gentoo.org/releases/arm64/autobuilds/20250309T234826Z/di-arm64-cloudinit-20250309T234826Z.qcow2" ;; if [[ "${ARCH,,}" != "arm64" ]]; then
body=$(pipe "https://mirror.bytemark.co.uk/gentoo/releases/amd64/autobuilds/latest-iso.txt") || exit 65
version=$(echo "$body" | grep livegui | cut -d' ' -f1)
url="https://distfiles.gentoo.org/releases/amd64/autobuilds/$version"
else
body=$(pipe "https://mirror.bytemark.co.uk/gentoo/releases/arm64/autobuilds/latest-qcow2.txt") || exit 65
version=$(echo "$body" | grep cloudinit | cut -d' ' -f1)
arm="https://distfiles.gentoo.org/releases/arm64/autobuilds/$version"
fi
fi ;;
"kali" | "kalilinux" | "kali-linux" ) "kali" | "kalilinux" | "kali-linux" )
name="Kali Linux" name="Kali Linux"
url="https://cdimage.kali.org/kali-2024.4/kali-linux-2024.4-live-amd64.iso" if [[ "$ret" == "url" ]]; then
arm="https://cdimage.kali.org/kali-2024.4/kali-linux-2024.4-live-arm64.iso" ;; body=$(pipe "https://cdimage.kali.org/current/?C=M;O=D") || exit 65
version=$(echo "$body" | grep -o ">kali-linux-.*-live-amd64.iso" | head -n 1 | cut -c 2-)
url="https://cdimage.kali.org/current/$version"
version=$(echo "$body" | grep -o ">kali-linux-.*-live-arm64.iso" | head -n 1 | cut -c 2-)
arm="https://cdimage.kali.org/current/$version"
fi ;;
"kubuntu" ) "kubuntu" )
name="Kubuntu" name="Kubuntu"
url="https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso" ;; if [[ "$ret" == "url" ]]; then
url="https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso"
fi ;;
"lmde" )
name="Linux Mint Debian Edition"
if [[ "$ret" == "url" ]]; then
url="https://mirror.rackspace.com/linuxmint/iso/debian/lmde-6-cinnamon-64bit.iso"
fi ;;
"macos" | "osx" ) "macos" | "osx" )
name="macOS" name="macOS"
error "To install $name use: https://github.com/dockur/macos" && return 1 ;; error "To install $name use: https://github.com/dockur/macos" && return 1 ;;
"mint" | "linuxmint" | "linux-mint" ) "mint" | "linuxmint" | "linux-mint" )
name="Linux Mint" name="Linux Mint"
url="https://mirrors.layeronline.com/linuxmint/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso" ;; if [[ "$ret" == "url" ]]; then
url="https://mirrors.layeronline.com/linuxmint/stable/22.1/linuxmint-22.1-cinnamon-64bit.iso"
fi ;;
"manjaro" ) "manjaro" )
name="Manjaro" name="Manjaro"
url="https://download.manjaro.org/kde/24.2.1/manjaro-kde-24.2.1-241216-linux612.iso" ;; if [[ "$ret" == "url" ]]; then
body=$(pipe "https://gitlab.manjaro.org/web/iso-info/-/raw/master/file-info.json") || exit 65
url=$(echo "$body" | jq -r .official.plasma.image)
fi ;;
"mx" | "mxlinux" | "mx-linux" ) "mx" | "mxlinux" | "mx-linux" )
name="MX Linux" name="MX Linux"
url="https://mirror.umd.edu/mxlinux-iso/MX/Final/Xfce/MX-23.5_x64.iso" ;; if [[ "$ret" == "url" ]]; then
version=$(curl --disable -Ils "https://sourceforge.net/projects/mx-linux/files/latest/download" | grep -i 'location:' | cut -d? -f1 | cut -d_ -f1 | cut -d- -f3) || exit 65
url="https://mirror.umd.edu/mxlinux-iso/MX/Final/Xfce/MX-${version}_x64.iso"
fi ;;
"nixos" ) "nixos" )
name="NixOS" name="NixOS"
url="https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-x86_64-linux.iso" if [[ "$ret" == "url" ]]; then
arm="https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-aarch64-linux.iso" ;; body=$(pipe "https://nix-channels.s3.amazonaws.com/?delimiter=/") || exit 65
version=$(echo "$body" | grep -o -E 'nixos-[[:digit:]]+\.[[:digit:]]+' | cut -d- -f2 | sort -nru | head -n 1)
url="https://channels.nixos.org/nixos-$version/latest-nixos-gnome-x86_64-linux.iso"
arm="https://channels.nixos.org/nixos-$version/latest-nixos-gnome-aarch64-linux.iso"
fi ;;
"opensuse" | "open-suse" | "suse" ) "opensuse" | "open-suse" | "suse" )
name="OpenSUSE" name="OpenSUSE"
url="https://download.opensuse.org/distribution/leap/15.0/live/openSUSE-Leap-15.0-GNOME-Live-x86_64-Current.iso" ;; if [[ "$ret" == "url" ]]; then
body=$(pipe "https://download.opensuse.org/distribution/leap/") || exit 65
version=$(echo "$body" | grep 'class="name"' | cut -d '/' -f2 | grep -v 42 | sort -r | head -n 1)
url="https://download.opensuse.org/distribution/leap/$version/installer/iso/agama-installer-Leap.x86_64-Leap.iso"
arm="https://download.opensuse.org/distribution/leap/$version/installer/iso/agama-installer-Leap.aarch64-Leap.iso"
fi ;;
"oracle" | "oraclelinux" | "oracle-linux" ) "oracle" | "oraclelinux" | "oracle-linux" )
name="Oracle Linux" name="Oracle Linux"
url="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/x86_64/OracleLinux-R9-U5-x86_64-boot.iso" if [[ "$ret" == "url" ]]; then
arm="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/aarch64/OracleLinux-R9-U5-aarch64-boot-uek.iso" ;; url="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/x86_64/OracleLinux-R9-U5-x86_64-boot.iso"
arm="https://yum.oracle.com/ISOS/OracleLinux/OL9/u5/aarch64/OracleLinux-R9-U5-aarch64-boot-uek.iso"
fi ;;
"rocky" | "rockylinux" | "rocky-linux" ) "rocky" | "rockylinux" | "rocky-linux" )
name="Rocky Linux" name="Rocky Linux"
url="https://dl.rockylinux.org/pub/rocky/9/live/x86_64/Rocky-9-Workstation-x86_64-latest.iso" if [[ "$ret" == "url" ]]; then
arm="https://dl.rockylinux.org/pub/rocky/9/live/aarch64/Rocky-9-Workstation-aarch64-latest.iso" ;; url="https://dl.rockylinux.org/pub/rocky/9/live/x86_64/Rocky-9-Workstation-x86_64-latest.iso"
arm="https://dl.rockylinux.org/pub/rocky/9/live/aarch64/Rocky-9-Workstation-aarch64-latest.iso"
fi ;;
"slack" | "slackware" ) "slack" | "slackware" )
name="Slackware" name="Slackware"
url="https://slackware.nl/slackware-live/slackware64-15.0-live/slackware64-live-15.0.iso" ;; if [[ "$ret" == "url" ]]; then
url="https://slackware.nl/slackware-live/slackware64-current-live/slackware64-live-current.iso"
fi ;;
"tails" ) "tails" )
name="Tails" name="Tails"
url="https://download.tails.net/tails/stable/tails-amd64-6.13/tails-amd64-6.13.img" ;; if [[ "$ret" == "url" ]]; then
body=$(pipe "https://tails.net/install/v2/Tails/amd64/stable/latest.json") || exit 65
url=$(echo "$body" | jq -r '.installations[0]."installation-paths"[]|select(.type=="iso")|."target-files"[0].url')
fi ;;
"ubuntu" | "ubuntu-desktop" ) "ubuntu" | "ubuntu-desktop" )
name="Ubuntu Desktop" name="Ubuntu Desktop"
url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-desktop-amd64.iso" if [[ "$ret" == "url" ]]; then
arm="https://cdimage.ubuntu.com/ubuntu/releases/24.10/release/ubuntu-24.10-desktop-arm64.iso" ;; url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-desktop-amd64.iso"
arm="https://cdimage.ubuntu.com/ubuntu/releases/24.10/release/ubuntu-24.10-desktop-arm64.iso"
fi ;;
"ubuntus" | "ubuntu-server") "ubuntus" | "ubuntu-server")
name="Ubuntu Server" name="Ubuntu Server"
url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso" if [[ "$ret" == "url" ]]; then
arm="https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04.2-live-server-arm64.iso" ;; url="https://releases.ubuntu.com/24.04.2/ubuntu-24.04.2-live-server-amd64.iso"
arm="https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04.2-live-server-arm64.iso"
fi ;;
"windows" ) "windows" )
name="Windows" name="Windows"
error "To install $name use: https://github.com/dockur/windows" && return 1 ;; error "To install $name use: https://github.com/dockur/windows" && return 1 ;;
"xubuntu" ) "xubuntu" )
name="Xubuntu" name="Xubuntu"
url="https://mirror.us.leaseweb.net/ubuntu-cdimage/xubuntu/releases/24.04/release/xubuntu-24.04.2-desktop-amd64.iso" ;; if [[ "$ret" == "url" ]]; then
url="https://mirror.us.leaseweb.net/ubuntu-cdimage/xubuntu/releases/24.04/release/xubuntu-24.04.2-desktop-amd64.iso"
fi ;;
esac esac
if [[ "${ARCH,,}" != "arm64" ]]; then
if [ -n "$name" ] && [ -z "$url" ]; then
error "No image for $name available!"
return 1
fi
else
if [ -n "$name" ] && [ -z "$arm" ]; then
error "No image for $name is available for ARM64 yet! "
return 1
fi
fi
case "${ret,,}" in case "${ret,,}" in
"test" )
;;
"name" ) "name" )
echo "$name" echo "$name"
;; ;;
*) "url" )
if [[ "${ARCH,,}" != "arm64" ]]; then
if [ -n "$name" ] && [ -z "$url" ]; then
error "No image for $name available!"
return 1
fi
else
if [ -n "$name" ] && [ -z "$arm" ]; then
error "No image for $name is available for ARM64 yet! "
return 1
fi
fi
if [[ "${ARCH,,}" != "arm64" ]]; then if [[ "${ARCH,,}" != "arm64" ]]; then
echo "$url" echo "$url"
else else

View file

@ -617,11 +617,7 @@ if [ -z "$DISK_FMT" ]; then
if [ -f "$DISK1_FILE.qcow2" ]; then if [ -f "$DISK1_FILE.qcow2" ]; then
DISK_FMT="qcow2" DISK_FMT="qcow2"
else else
if [[ "$BOOT" == *".qcow2" ]] && [ ! -f "$DISK1_FILE.img" ]; then DISK_FMT="raw"
DISK_FMT="qcow2"
else
DISK_FMT="raw"
fi
fi fi
fi fi

View file

@ -222,10 +222,8 @@ if [ -z "$BOOT" ] || [[ "$BOOT" == *"example.com/image.iso" ]]; then
error "No value specified for the BOOT variable." && exit 64 error "No value specified for the BOOT variable." && exit 64
fi fi
! getURL "$BOOT" "test" && exit 34 url=$(getURL "$BOOT" "url") || exit 34
name=$(getURL "$BOOT" "name") || exit 34
url=$(getURL "$BOOT" "url")
name=$(getURL "$BOOT" "name")
[ -n "$url" ] && BOOT="$url" [ -n "$url" ] && BOOT="$url"

View file

@ -49,7 +49,7 @@ configureDHCP() {
error "Cannot create macvtap interface. Please make sure that the network type of the container is 'macvlan' and not 'ipvlan'." error "Cannot create macvtap interface. Please make sure that the network type of the container is 'macvlan' and not 'ipvlan'."
return 1 ;; return 1 ;;
"RTNETLINK answers: Operation not permitted"* ) "RTNETLINK answers: Operation not permitted"* )
error "No permission to create macvtap interface. Please make sure that your host kernel supports it and that the NET_ADMIN capability is set." error "No permission to create macvtap interface. Please make sure that your host kernel supports it and that the NET_ADMIN capability is set."
return 1 ;; return 1 ;;
*) *)
[ -n "$msg" ] && echo "$msg" >&2 [ -n "$msg" ] && echo "$msg" >&2
@ -119,6 +119,12 @@ configureDNS() {
DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
if [[ "${DEBUG_DNS:-}" == [Yy1]* ]]; then
DNSMASQ_OPTS+=" -d"
$DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} &
return 0
fi
if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
error "Failed to start dnsmasq, reason: $?" && return 1 error "Failed to start dnsmasq, reason: $?" && return 1
fi fi
@ -214,7 +220,7 @@ configureNAT() {
fi fi
if ! ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge; then if ! ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge; then
error "Failed to add IP address!" && return 1 error "Failed to add IP address pool!" && return 1
fi fi
while ! ip link set dockerbridge up; do while ! ip link set dockerbridge up; do
@ -263,7 +269,7 @@ configureNAT() {
error "Failed to configure IP tables!" && return 1 error "Failed to configure IP tables!" && return 1
fi fi
if ! iptables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP" -p udp -j DNAT --to "$VM_NET_IP"; then if ! iptables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP" -p udp -j DNAT --to "$VM_NET_IP"; then
error "Failed to configure IP tables!" && return 1 error "Failed to configure IP tables!" && return 1
fi fi
@ -408,8 +414,15 @@ getInfo() {
error "Invalid MAC address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28 error "Invalid MAC address: '$VM_NET_MAC', should be 12 or 17 digits long!" && exit 28
fi fi
GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}') GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}' | head -n 1)
IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/ | head -n 1)
IP6=""
# shellcheck disable=SC2143
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
IP6=$(ip -6 addr show dev "$VM_NET_DEV" scope global up)
[ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
fi
return 0 return 0
} }
@ -436,8 +449,8 @@ if [[ "$DEBUG" == [Yy1]* ]]; then
fi fi
if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then if [[ -d "/sys/class/net/$VM_NET_TAP" ]]; then
info "Lingering interface will be removed..." info "Lingering interface will be removed..."
ip link delete "$VM_NET_TAP" || true ip link delete "$VM_NET_TAP" || true
fi fi
if [[ "$DHCP" == [Yy1]* ]]; then if [[ "$DHCP" == [Yy1]* ]]; then
@ -464,7 +477,7 @@ else
closeBridge closeBridge
NETWORK="user" NETWORK="user"
warn "falling back to usermode networking! Performance will be bad and port mapping will not work." warn "falling back to user-mode networking! Performance will be bad and port mapping will not work."
fi fi
@ -472,7 +485,7 @@ else
if [[ "${NETWORK,,}" == "user"* ]]; then if [[ "${NETWORK,,}" == "user"* ]]; then
# Configure for usermode networking (slirp) # Configure for user-mode networking (slirp)
configureUser || exit 24 configureUser || exit 24
fi fi

View file

@ -20,8 +20,8 @@ echo " For support visit $SUPPORT"
: "${MACHINE:="virt"}" # Machine selection : "${MACHINE:="virt"}" # Machine selection
: "${ALLOCATE:=""}" # Preallocate diskspace : "${ALLOCATE:=""}" # Preallocate diskspace
: "${ARGUMENTS:=""}" # Extra QEMU parameters : "${ARGUMENTS:=""}" # Extra QEMU parameters
: "${CPU_CORES:="1"}" # Amount of CPU cores : "${CPU_CORES:="2"}" # Amount of CPU cores
: "${RAM_SIZE:="1G"}" # Maximum RAM amount : "${RAM_SIZE:="2G"}" # Maximum RAM amount
: "${RAM_CHECK:="Y"}" # Check available RAM : "${RAM_CHECK:="Y"}" # Check available RAM
: "${DISK_SIZE:="16G"}" # Initial data disk size : "${DISK_SIZE:="16G"}" # Initial data disk size
: "${BOOT_MODE:=""}" # Boot system with UEFI : "${BOOT_MODE:=""}" # Boot system with UEFI
@ -69,6 +69,8 @@ CPU="${CPU// 8 Core/}"
CPU="${CPU// 16 Core/}" CPU="${CPU// 16 Core/}"
CPU="${CPU// 32 Core/}" CPU="${CPU// 32 Core/}"
CPU="${CPU// 64 Core/}" CPU="${CPU// 64 Core/}"
CPU="${CPU//10th Gen /}"
CPU="${CPU//11th Gen /}"
CPU="${CPU//12th Gen /}" CPU="${CPU//12th Gen /}"
CPU="${CPU//13th Gen /}" CPU="${CPU//13th Gen /}"
CPU="${CPU//14th Gen /}" CPU="${CPU//14th Gen /}"
@ -310,6 +312,19 @@ fi
# Set password # Set password
echo "$user:{PLAIN}${PASS:-}" > /etc/nginx/.htpasswd echo "$user:{PLAIN}${PASS:-}" > /etc/nginx/.htpasswd
# shellcheck disable=SC2143
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
sed -i "s/listen 80;/listen [::]:80 ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
sed -i "s/listen 8006 default_server;/listen [::]:8006 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
else
sed -i "s/listen [::]:80 ipv6only=off;/listen 80;/g" /etc/nginx/sites-enabled/web.conf
sed -i "s/listen [::]:8006 default_server ipv6only=off;/listen 8006 default_server;/g" /etc/nginx/sites-enabled/web.conf
fi
# Start webserver # Start webserver
cp -r /var/www/* /run/shm cp -r /var/www/* /run/shm
html "Starting $APP for Docker..." html "Starting $APP for Docker..."