Unverified Commit f381f9eb authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Improved installation (#63)

parent accd1799
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -15,10 +15,7 @@ RUN apt-get update \

COPY ./src /run/
COPY ./assets /run/assets

ADD https://github.com/qemus/virtiso/raw/master/virtio-win.iso /run/drivers.iso
ADD https://raw.githubusercontent.com/ElliotKillick/Mido/main/Mido.sh /run/mido.sh

RUN chmod +x /run/*.sh

EXPOSE 8006 3389
+5 −5
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ docker run -it --rm -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN dockurr/w
    
    - Start the container and get some coffee.

    - Connect to port 8006 of the container in your web browser.
    - Connect to [port 8006](http://localhost:8006) of the container in your web browser.

    - Sit back and relax while the magic happens, the whole installation will be performed fully automatic.

@@ -127,7 +127,7 @@ docker run -it --rm -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN dockurr/w

    Then follow these steps:

    - Start the container and connect to port 8006 of the container in your web browser. After the download is finished, you will see the Windows installation screen.
    - Start the container and connect to [port 8006](http://localhost:8006) of the container in your web browser. After the download is finished, you will see the Windows installation screen.

    - Start the installation by clicking ```Install now```. On the next screen, press 'OK' when prompted to ```Load driver``` and select the ```VirtIO SCSI``` driver from the list that matches your Windows version. So for Windows 11, select ```D:\amd64\w11\vioscsi.inf``` and click 'Next'.

@@ -143,16 +143,16 @@ docker run -it --rm -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN dockurr/w

    - Now your Windows installation is ready for use. Enjoy it, and don't forget to star this repo!

  * ### How do I install an unsupported version?
  * ### How do I install a custom image?

    You can specify an URL in the `VERSION` environment variable, in order to download a custom ISO image:
    In order to download a custom ISO image, specify an URL in the `VERSION` environment variable:
    
    ```yaml
    environment:
      VERSION: "https://example.com/win.iso"
    ```
    
    During the installation you may need to add some drivers as described in [manual installation](https://github.com/dockur/windows/tree/master?tab=readme-ov-file#how-do-i-perform-a-manual-installation) above.
    Make sure your `/storage` folder is empty before starting the container. Alternatively, you can also place a file called `custom.iso` in that folder to skip the download.

  * ### How do I pass-through a disk?

+89 −53
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
set -Eeuo pipefail

: "${MANUAL:=""}"
: "${EXTERNAL:=""}"
: "${VERSION:="win11x64"}"

[[ "${VERSION,,}" == "11" ]] && VERSION="win11x64"
@@ -48,12 +47,10 @@ fi

MSG="Windows is being started, please wait..."

BASE="custom.iso"
if [ ! -f "$STORAGE/$BASE" ]; then

if [[ "$EXTERNAL" != [Yy1]* ]]; then

  BASE="$VERSION.iso"

  if [ ! -f "$STORAGE/$BASE" ]; then
    MSG="Windows is being downloaded, please wait..."
  fi
@@ -69,29 +66,43 @@ if [ ! -f "$STORAGE/$BASE" ]; then
  fi

fi
fi

html "$MSG"

[ -f "$STORAGE/$BASE" ] && return 0
[[ "${BASE,,}" == "custom."* ]] && BASE="target.iso"

html "$MSG"
TMP="$STORAGE/tmp"

if [ -f "$STORAGE/$BASE" ]; then
  rm -rf "$TMP"
  return 0
fi

mkdir -p "$TMP"

ISO="$TMP/$BASE"
rm -f "$ISO"

if [[ "$EXTERNAL" != [Yy1]* ]]; then
CUSTOM="custom.iso"

[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.img"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="Custom.iso"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="Custom.img"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.ISO"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="custom.IMG"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="CUSTOM.ISO"
[ ! -f "$STORAGE/$CUSTOM" ] && CUSTOM="CUSTOM.IMG"

  SCRIPT="$TMP/mido.sh"
if [ ! -f "$STORAGE/$CUSTOM" ]; then
  CUSTOM=""
else
  ISO="$STORAGE/$CUSTOM"
fi

if [ ! -f "$ISO" ]; then
  if [[ "$EXTERNAL" != [Yy1]* ]]; then

  rm -f "$SCRIPT"
  cp /run/mido.sh "$SCRIPT"
  chmod +x "$SCRIPT"
    cd "$TMP"
  bash "$SCRIPT" "$VERSION"
  rm -f "$SCRIPT"
    /run/mido.sh "$VERSION"
    cd /run

  else
@@ -112,14 +123,28 @@ else
  fi

  [ ! -f "$ISO" ] && echo && error "Failed to download $VERSION" && exit 61
fi

SIZE=$(stat -c%s "$ISO")
SIZE_GB=$(( (SIZE + 1073741823)/1073741824 ))

if ((SIZE<10000000)); then
  echo && error "Invalid ISO file: Size is smaller than 10 MB" && exit 62
fi

SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))

if (( SIZE > SPACE )); then
  error "Not enough free space in $STORAGE, have $SPACE_GB GB available but need at least $SIZE_GB GB." && exit 63
fi

if [ -n "$CUSTOM" ]; then
  MSG="Extracting custom ISO image..."
else
  MSG="Extracting downloaded ISO image..."
fi

echo && info "$MSG" && html "$MSG"

DIR="$TMP/unpack"
@@ -138,11 +163,13 @@ if [ ! -f "$DIR/$ETFS" ] || [ ! -f "$DIR/$EFISYS" ]; then
  else
    warn "failed to locate file 'efisys_noprompt.bin' in ISO image, $FB"
  fi
  mv "$ISO" "$STORAGE/$BASE"
  mv -f "$ISO" "$STORAGE/$BASE"
  rm -rf "$TMP"
  echo && return 0
fi

[ -z "$CUSTOM" ] && rm -f "$ISO"

if [ -z "$MANUAL" ]; then

  MANUAL="N"
@@ -156,11 +183,10 @@ fi
XML=""

if [[ "$MANUAL" != [Yy1]* ]]; then
  if [[ "$EXTERNAL" != [Yy1]* ]]; then

    XML="$VERSION.xml"
  [[ "$EXTERNAL" != [Yy1]* ]] && XML="$VERSION.xml"

  else
  if [ ! -f "/run/assets/$XML" ]; then

    MSG="Detecting Windows version from ISO image..."
    info "$MSG" && html "$MSG"
@@ -190,7 +216,12 @@ if [[ "$MANUAL" != [Yy1]* ]]; then
      if [ -n "$DETECTED" ]; then

        XML="$DETECTED.xml"
        echo "Detected image of type '$DETECTED', will apply autounattend.xml file."

        if [ -f "/run/assets/$XML" ]; then
          echo "Detected image of type '$DETECTED', will apply an autounattend.xml file."
        else
          warn "detected image of type '$DETECTED', but no matching .xml file exists, $FB."
        fi

      else
        if [ -z "$NAME" ]; then
@@ -255,25 +286,30 @@ if [ -f "$ASSET" ]; then

  echo

else
  if [ -n "$XML" ]; then
    warn "XML file '$XML' does not exist, $FB" && echo
  fi
fi

CAT="BOOT.CAT"
LABEL="${BASE%.*}"
LABEL="${LABEL::30}"
ISO="$TMP/$LABEL.tmp"
rm -f "$ISO"
OUT="$TMP/$LABEL.tmp"
rm -f "$OUT"

SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
SPACE_GB=$(( (SPACE + 1073741823)/1073741824 ))

if (( SIZE > SPACE )); then
  error "Not enough free space in $STORAGE, have $SPACE_GB GB available but need at least $SIZE_GB GB." && exit 63
fi

MSG="Generating new ISO image for installation..."
info "$MSG" && html "$MSG"

genisoimage -b "$ETFS" -no-emul-boot -c "$CAT" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -quiet -V "$LABEL" -udf \
                       -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -o "$ISO" -allow-limited-size "$DIR"
                       -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -o "$OUT" -allow-limited-size "$DIR"

[ -n "$CUSTOM" ] && rm -f "$STORAGE/$CUSTOM"

mv "$ISO" "$STORAGE/$BASE"
mv "$OUT" "$STORAGE/$BASE"
rm -rf "$TMP"

html "Successfully prepared image for installation..."

src/mido.sh

0 → 100644
+766 −0

File added.

Preview size limit exceeded, changes collapsed.