Compare commits

...

91 Commits

Author SHA1 Message Date
Kroese
077d4aadd9
Update install.sh 2024-05-03 15:29:23 +02:00
Kroese
00c54e7e20
Update install.sh 2024-05-03 15:19:15 +02:00
Kroese
1f99fafb47
Update install.sh 2024-05-03 14:25:05 +02:00
Kroese
12a3cb13ec
Update install.sh 2024-05-03 14:08:26 +02:00
Kroese
9102e41ca9
Update install.sh 2024-05-03 14:05:32 +02:00
Kroese
da861b3467
Update define.sh 2024-05-03 12:46:43 +02:00
Kroese
66ba07e5f9
Update install.sh 2024-05-03 12:21:46 +02:00
Kroese
ab0bcfe718
Update check.yml 2024-05-03 11:43:04 +02:00
Kroese
8841297f97
Update Dockerfile 2024-05-03 11:41:46 +02:00
Kroese
443e577be3
Update install.sh 2024-05-03 11:35:41 +02:00
Kroese
5f3341f9eb
Update Dockerfile 2024-05-03 11:29:12 +02:00
Kroese
284dc7bfb9
Update readme.md 2024-05-03 05:39:58 +02:00
Kroese
3d05627eea
Update define.sh 2024-05-03 05:18:58 +02:00
Kroese
2d00d92b9d
Update install.sh 2024-05-03 04:59:24 +02:00
Kroese
c3c80463c9
Update install.sh 2024-05-03 04:48:28 +02:00
Kroese
e62d790f99
Update install.sh 2024-05-03 04:02:46 +02:00
Kroese
e58f4c432c
Update mido.sh 2024-05-03 03:07:14 +02:00
Kroese
47b260737e
Update define.sh 2024-05-03 02:14:45 +02:00
Kroese
49d15eba69
Update install.sh 2024-05-03 01:54:23 +02:00
Kroese
e33cb688c9
Update install.sh 2024-05-03 01:37:59 +02:00
Kroese
c6c487639e
Update define.sh 2024-05-03 01:34:19 +02:00
Kroese
4c45911a62
Update define.sh 2024-05-03 01:19:06 +02:00
Kroese
526e14c448
Update install.sh 2024-05-02 23:58:44 +02:00
Kroese
92019dc1ba
Update define.sh 2024-05-02 23:48:41 +02:00
Kroese
eff399c393
Update install.sh 2024-05-02 23:10:18 +02:00
Kroese
3bab3b956f
Update install.sh 2024-05-02 22:55:24 +02:00
Kroese
fd9a1349b0
Update define.sh 2024-05-02 22:54:00 +02:00
Kroese
d3baf11dd4
Update power.sh 2024-05-02 22:14:10 +02:00
Kroese
e6a72cf68b
Update samba.sh 2024-05-02 22:09:53 +02:00
Kroese
4a5b91f111
Update install.sh 2024-05-02 21:18:58 +02:00
Kroese
48d2019fe9
build: Update qemu-docker to v4.28 2024-05-02 20:42:48 +02:00
Kroese
5bcc7f017f
Update install.sh 2024-05-02 18:09:20 +02:00
Kroese
0fbd2ba87f
Update define.sh 2024-05-02 18:04:57 +02:00
Kroese
77ebef8d01
Update define.sh 2024-05-02 17:57:38 +02:00
Kroese
ce408be189
Update define.sh 2024-05-02 17:47:16 +02:00
Kroese
14b72b4d6c
Update install.sh 2024-05-02 17:05:51 +02:00
Kroese
40ec19556d
Update define.sh 2024-05-02 12:31:43 +02:00
Kroese
4a9659e57b
feat: Detect changed ISO files 2024-05-02 12:10:06 +02:00
Kroese
face13d3de
Update install.sh 2024-05-02 11:24:51 +02:00
Kroese
b1ef535b87
Update install.sh 2024-05-02 02:34:05 +02:00
Kroese
0e8a1179aa
Update define.sh 2024-05-02 02:09:41 +02:00
Kroese
6035149bcb
Update define.sh 2024-05-02 02:07:09 +02:00
Kroese
bacd4eae07
Update define.sh 2024-05-02 01:30:56 +02:00
Kroese
2d78c763d1
Update readme.md 2024-05-02 00:52:02 +02:00
Kroese
6201d2cc0a
Update define.sh 2024-05-02 00:50:54 +02:00
Kroese
5ebd2bd4f7
Update readme.md 2024-05-02 00:11:16 +02:00
Kroese
6be9c106f0
docs: Readme 2024-05-01 23:59:28 +02:00
Kroese
e43abe8adf
Update install.sh 2024-05-01 23:17:03 +02:00
Kroese
de246580e8
Update winvistax64.xml 2024-05-01 22:59:15 +02:00
Kroese
1d79b844ba
Update winvistax64.xml 2024-05-01 22:58:31 +02:00
Kroese
ae3f1b0c11
Update win7x64.xml 2024-05-01 22:44:02 +02:00
Kroese
02db4ec713
Update define.sh 2024-05-01 22:34:39 +02:00
Kroese
865802e04b
Update install.sh 2024-05-01 22:29:54 +02:00
Kroese
648d64869b
Update install.sh 2024-05-01 22:18:15 +02:00
Kroese
c9bf0e50ab
Update install.sh 2024-05-01 21:34:03 +02:00
Kroese
9628a4c160
fix: Image detection 2024-05-01 20:52:47 +02:00
Kroese
52581d5303
Update install.sh 2024-05-01 20:04:21 +02:00
Kroese
1dcf445b23
Update install.sh 2024-05-01 20:02:20 +02:00
Kroese
40aa11e6a6
Update install.sh 2024-05-01 19:49:32 +02:00
Kroese
b93104c341
Update install.sh 2024-05-01 19:48:32 +02:00
Kroese
72e8bdf62e
Update install.sh 2024-05-01 19:40:11 +02:00
Kroese
e8b3066bc6
feat: Verify downloads 2024-05-01 19:36:43 +02:00
Kroese
23e2f1cbb4
Update define.sh 2024-05-01 19:07:08 +02:00
Kroese
a70b0942fe
Update define.sh 2024-05-01 18:42:34 +02:00
Kroese
28b555685b
Update install.sh 2024-05-01 18:41:42 +02:00
Kroese
e3fbef5fda
Update define.sh 2024-05-01 18:30:51 +02:00
Kroese
a27777b496
Update Dockerfile 2024-05-01 18:25:58 +02:00
Kroese
49d7d0e2b2
Update define.sh 2024-05-01 18:25:43 +02:00
Kroese
fa69457de5
feat: Preserve original ISO label 2024-05-01 18:10:33 +02:00
Kroese
c36451b431
feat: Refactor 2024-05-01 17:30:24 +02:00
Kroese
116bb06b50
Update install.sh 2024-05-01 16:58:13 +02:00
Kroese
9ac1465b3d
Update install.sh 2024-05-01 15:02:05 +02:00
Kroese
6779ac0f36
Update install.sh 2024-05-01 14:51:56 +02:00
Kroese
48144c53e9
docs: Vista Enterprise 2024-05-01 14:09:49 +02:00
Kroese
4021b30b16
fix: Timeout detection 2024-05-01 11:22:24 +02:00
Kroese
535b77c918
Update define.sh 2024-05-01 05:49:18 +02:00
Kroese
b0ba70a466
Update install.sh 2024-05-01 05:47:20 +02:00
Kroese
7a26efa00c
Update define.sh 2024-05-01 05:46:43 +02:00
Kroese
4b8fb34019
Update install.sh 2024-05-01 05:42:55 +02:00
Kroese
74ccbdcea8
Update define.sh 2024-05-01 05:38:23 +02:00
Kroese
5b768ba463
Update install.sh 2024-05-01 05:29:51 +02:00
Kroese
2d00319306
Update define.sh 2024-05-01 05:23:39 +02:00
Kroese
da18118778
Update install.sh 2024-05-01 05:16:16 +02:00
Kroese
fc5bdce509
Update define.sh 2024-05-01 05:08:01 +02:00
Kroese
50487d34f8
Update define.sh 2024-05-01 04:47:58 +02:00
Kroese
6a5c634471
Update define.sh 2024-05-01 03:41:18 +02:00
Kroese
2d1e695813
feat: Windows XP 64-bit key 2024-05-01 03:09:31 +02:00
Kroese
d123dd5bc9
feat: Additional mirrors 2024-05-01 02:40:27 +02:00
Kroese
aec44f2668
feat: Additional mirrors 2024-05-01 02:34:21 +02:00
Kroese
279d3d1dfe
build: Update qemu-docker to v4.28 2024-05-01 00:11:28 +02:00
Kroese
3b9147b2fc
docs: Disk pass-through 2024-05-01 00:10:54 +02:00
10 changed files with 945 additions and 604 deletions

View File

@ -21,5 +21,5 @@ jobs:
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
ignore: DL3008,DL4006,SC3037
ignore: DL3008
failure-threshold: warning

View File

@ -1,5 +1,5 @@
FROM scratch
COPY --from=qemux/qemu-docker:4.27 / /
COPY --from=qemux/qemu-docker:5.00 / /
ARG DEBCONF_NOWARNINGS "yes"
ARG DEBIAN_FRONTEND "noninteractive"
@ -12,14 +12,11 @@ RUN apt-get update && \
7zip \
wsdd \
samba \
wimtools \
dos2unix \
cabextract \
genisoimage \
libxml2-utils && \
echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list.d/sid.list && \
echo -e "Package: *\nPin: release n=trixie\nPin-Priority: 900\nPackage: *\nPin: release n=sid\nPin-Priority: 400" | tee /etc/apt/preferences.d/preferences > /dev/null && \
apt-get update && \
apt-get -t sid --no-install-recommends -y install wimtools && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@ -52,8 +52,8 @@
<OSImage>
<InstallFrom>
<MetaData wcm:action="add">
<Value>1</Value>
<Key>/IMAGE/INDEX</Key>
<Value>Windows 7 PROFESSIONAL</Value>
<Key>/IMAGE/NAME</Key>
</MetaData>
</InstallFrom>
<InstallTo>
@ -76,7 +76,7 @@
<FullName>Docker</FullName>
<Organization>Windows for Docker</Organization>
<ProductKey>
<Key>H7X92-3VPBB-Q799D-Y6JJ3-86WC6</Key>
<Key>HYF8J-CVRMY-CM74G-RPHKF-PW487</Key>
<WillShowUI>OnError</WillShowUI>
</ProductKey>
</UserData>

View File

@ -51,7 +51,7 @@
<OSImage>
<InstallFrom>
<MetaData wcm:action="add">
<Value>Windows Vista Ultimate</Value>
<Value>Windows Vista BUSINESS</Value>
<Key>/IMAGE/NAME</Key>
</MetaData>
</InstallFrom>
@ -68,7 +68,7 @@
<FullName>Docker</FullName>
<Organization>Windows for Docker</Organization>
<ProductKey>
<Key>VMCB9-FDRV6-6CDQM-RV23K-RP8F7</Key>
<Key>4D2XH-PRBMM-8Q22B-K8BM3-MRW4W</Key>
</ProductKey>
</UserData>
</component>
@ -100,7 +100,7 @@
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<ComputerName>*</ComputerName>
<ProductKey>VMCB9-FDRV6-6CDQM-RV23K-RP8F7</ProductKey>
<ProductKey>4D2XH-PRBMM-8Q22B-K8BM3-MRW4W</ProductKey>
<TimeZone>Pacific Standard Time</TimeZone>
<OEMInformation>
<Manufacturer>Dockur</Manufacturer>

117
readme.md
View File

@ -88,7 +88,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
| `win81` | Windows 8.1 Pro | 4.2 GB |
| `win81e` | Windows 8.1 Enterprise | 3.8 GB |
| `win7` | Windows 7 Enterprise | 3.0 GB |
| `vista` | Windows Vista Ultimate | 3.6 GB |
| `vista` | Windows Vista Enterprise | 3.0 GB |
| `winxp` | Windows XP Professional | 0.6 GB |
||||
| `2022` | Windows Server 2022 | 4.7 GB |
@ -103,37 +103,6 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
To install ARM64 versions of Windows use [dockur/windows-arm](https://github.com/dockur/windows-arm/).
* ### How do I connect using RDP?
The web-viewer is mainly meant to be used during installation, as its picture quality is low, and it has no audio or clipboard for example.
So for a better experience you can connect using any Microsoft Remote Desktop client to the IP of the container, using the username `docker` and by leaving the password empty.
There is a good RDP client for [Android](https://play.google.com/store/apps/details?id=com.microsoft.rdc.androidx) available from the Play Store and one for [iOS](https://apps.apple.com/nl/app/microsoft-remote-desktop/id714464092?l=en-GB) in the Apple Store. For Linux you can use [FreeRDP](https://www.freerdp.com/) and on Windows just type `mstsc` in the search box.
* ### How do I increase the amount of CPU or RAM?
By default, 2 CPU cores and 4 GB of RAM are allocated to the container, as those are the minimum requirements of Windows 11.
To increase this, add the following environment variables:
```yaml
environment:
RAM_SIZE: "8G"
CPU_CORES: "4"
```
* ### How do I change the size of the disk?
To expand the default size of 64 GB, add the `DISK_SIZE` setting to your compose file and set it to your preferred capacity:
```yaml
environment:
DISK_SIZE: "256G"
```
This can also be used to resize the existing disk to a larger capacity without any data loss.
* ### How do I change the storage location?
To change the storage location, include the following bind mount in your compose file:
@ -145,40 +114,53 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
Replace the example path `/var/win` with the desired storage folder.
* ### How do I change the size of the disk?
To expand the default size of 64 GB, add the `DISK_SIZE` setting to your compose file and set it to your preferred capacity:
```yaml
environment:
DISK_SIZE: "256G"
```
This can also be used to resize the existing disk to a larger capacity without any data loss.
* ### How do I share files with the host?
Open File Explorer and click on the Network section, you will see a computer called `host.lan`, double-click it and it will show a folder called `Data`.
Open 'File Explorer' and click on the 'Network' section, you will see a computer called `host.lan`, double-click it and it will show a folder called `Data`.
Inside this folder you can access any files that are placed in `/storage/shared` (see above) on the host.
Inside this folder you can access any files that are placed in `/storage/shared` (see above) on the host. You can optionally map it to a drive letter, for easy access.
* ### How do I install a custom image?
In order to download a custom ISO image, start a fresh container with the URL of the ISO specified in the `VERSION` environment variable:
In order to download any ISO image that is not part of the list above, start a fresh container with the URL of that ISO specified in the `VERSION` environment variable, for example:
```yaml
environment:
VERSION: "https://example.com/win.iso"
```
Alternatively, you can also use a local file directly, and skip the download, by binding it in your compose file in this way:
Alternatively, you can also use a local file directly, and skip the download altogether, by binding it in your compose file in this way:
```yaml
volumes:
- /home/user/example.iso:/storage/custom.iso
```
Replace the example path `/home/user/example.iso` with the filename of the desired ISO file. The value of `VERSION` will be ignored in this case.
Replace the example path `/home/user/example.iso` with the filename of your desired ISO file. The value of `VERSION` will be ignored in this case.
* ### How do I customize the installation?
You can customize every setting used by the automatic installation. Download the XML file corresponding to your Windows version, for example [win11x64.xml](https://raw.githubusercontent.com/dockur/windows/master/assets/win11x64.xml). Then apply your modifications to it, and add this line to your compose file:
If you want to modify the settings used during the automatic installation, you can do this by editing the answer file corresponding to your Windows edition, for example [win11x64.xml](https://raw.githubusercontent.com/dockur/windows/master/assets/win11x64.xml) in the case of Windows 11 Pro.
Apply your modifications to it, and add this line to your compose file:
```yaml
volumes:
- /home/user/custom.xml:/run/assets/win11x64.xml
- /home/user/example.xml:/storage/custom.xml
```
Replace the example path `/home/user/custom.xml` with the filename of the modified XML file.
Replace the example path `/home/user/example.xml` with the filename of the modified XML file.
* ### How do I run a script after installation?
@ -189,7 +171,7 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
- /home/user/example:/storage/oem
```
The example path `/home/user/example` will be copied to `C:\OEM` during installation and the containing `install.bat` will be executed.
The example folder `/home/user/example` will be copied to `C:\OEM` during installation and the containing `install.bat` will be executed during the last step.
* ### How do I perform a manual installation?
@ -219,6 +201,37 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
- Once you see the desktop, open File Explorer and navigate to the CD-ROM drive (E:). Double-click on `virtio-win-gt-x64.msi` and proceed to install the VirtIO drivers.
Enjoy your brand new machine, and don't forget to star this repo!
* ### How do I verify if my system supports KVM?
To verify if your system supports KVM, run the following commands:
```bash
sudo apt install cpu-checker
sudo kvm-ok
```
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.
* ### How do I increase the amount of CPU or RAM?
By default, 2 CPU cores and 4 GB of RAM are allocated to the container, as those are the minimum requirements of Windows 11.
If there arises a need to increase this, add the following environment variables:
```yaml
environment:
RAM_SIZE: "8G"
CPU_CORES: "4"
```
* ### How do I connect using RDP?
The web-viewer is mainly meant to be used during installation, as its picture quality is low, and it has no audio or clipboard for example.
So for a better experience you can connect using any Microsoft Remote Desktop client to the IP of the container, using the username `docker` and by leaving the password empty.
There is a good RDP client for [Android](https://play.google.com/store/apps/details?id=com.microsoft.rdc.androidx) available from the Play Store and one for [iOS](https://apps.apple.com/nl/app/microsoft-remote-desktop/id714464092?l=en-GB) in the Apple Store. For Linux you can use [FreeRDP](https://www.freerdp.com/) and on Windows just type `mstsc` in the search box.
* ### How do I assign an individual IP address to the container?
@ -272,21 +285,18 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
```
Please note that in this mode, the container and Windows will each have their own separate IPs. The container will keep the macvlan IP, and Windows will use the DHCP IP.
* ### How do I pass-through a disk?
It is possible to pass-through disk devices directly by adding them to your compose file in this way:
```yaml
environment:
DEVICE: "/dev/sda"
DEVICE2: "/dev/sdb"
devices:
- /dev/sda
- /dev/sdb
- /dev/sdb:/dev/disk1
- /dev/sdc:/dev/disk2
```
Use `DEVICE` if you want it to become your main drive, and use `DEVICE2` and higher to add them as secondary drives.
Use `/dev/disk1` if you want it to become your main drive, and use `/dev/disk2` and higher to add them as secondary drives.
* ### How do I pass-through a USB device?
@ -298,17 +308,6 @@ docker run -it --rm --name windows -p 8006:8006 --device=/dev/kvm --cap-add NET_
devices:
- /dev/bus/usb
```
* ### How do I verify if my system supports KVM?
To verify if your system supports KVM, run the following commands:
```bash
sudo apt install cpu-checker
sudo kvm-ok
```
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.
* ### Is this project legal?

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash
set -Eeuo pipefail
ESD_URL=""
TMP="$STORAGE/tmp"
DIR="$TMP/unpack"
FB="falling back to manual installation!"
@ -28,65 +27,6 @@ skipInstall() {
return 1
}
finishInstall() {
local iso="$1"
local aborted="$2"
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
error "Failed to find ISO file: $iso" && return 1
fi
if [ -w "$iso" ] && [[ "$aborted" != [Yy1]* ]]; then
# Mark ISO as prepared via magic byte
if ! printf '\x16' | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then
error "Failed to set magic byte in ISO file: $iso" && return 1
fi
fi
rm -f "$STORAGE/windows.ver"
rm -f "$STORAGE/windows.old"
rm -f "$STORAGE/windows.boot"
rm -f "$STORAGE/windows.mode"
cp /run/version "$STORAGE/windows.ver"
if [[ "${PLATFORM,,}" == "x64" ]]; then
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
if [[ "${MACHINE,,}" != "q35" ]]; then
echo "$MACHINE" > "$STORAGE/windows.old"
fi
else
# Enable secure boot + TPM on manual installs as Win11 requires
if [[ "$MANUAL" == [Yy1]* ]] || [[ "$aborted" == [Yy1]* ]]; then
if [[ "${DETECTED,,}" == "win11"* ]]; then
BOOT_MODE="windows_secure"
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
fi
fi
fi
fi
rm -rf "$TMP"
return 0
}
abortInstall() {
local iso="$1"
if [[ "$iso" != "$STORAGE/$BASE" ]]; then
if ! mv -f "$iso" "$STORAGE/$BASE"; then
error "Failed to move ISO file: $iso" && return 1
fi
fi
finishInstall "$STORAGE/$BASE" "Y" && return 0
return 1
}
startInstall() {
html "Starting Windows..."
@ -95,7 +35,6 @@ startInstall() {
if [ -f "$STORAGE/$CUSTOM" ]; then
EXTERNAL="Y"
BASE="$CUSTOM"
else
@ -104,12 +43,10 @@ startInstall() {
if [[ "${VERSION,,}" != "http"* ]]; then
EXTERNAL="N"
BASE="$VERSION.iso"
else
EXTERNAL="Y"
BASE=$(basename "${VERSION%%\?*}")
: "${BASE//+/ }"; printf -v BASE '%b' "${_//%/\\x}"
BASE=$(echo "$BASE" | sed -e 's/[^A-Za-z0-9._-]/_/g')
@ -122,7 +59,10 @@ startInstall() {
fi
if skipInstall; then
[ ! -f "$STORAGE/$BASE" ] && BASE=""
if [ ! -f "$STORAGE/$BASE" ]; then
BASE="custom.iso"
[ ! -f "$STORAGE/$BASE" ] && BASE=""
fi
[[ "${PLATFORM,,}" == "arm64" ]] && VGA="virtio-gpu"
return 1
fi
@ -142,7 +82,6 @@ startInstall() {
fi
EXTERNAL="Y"
CUSTOM="$BASE"
fi
@ -160,19 +99,92 @@ startInstall() {
return 0
}
finishInstall() {
local iso="$1"
local aborted="$2"
if [ ! -s "$iso" ] || [ ! -f "$iso" ]; then
error "Failed to find ISO file: $iso" && return 1
fi
if [ -w "$iso" ] && [[ "$aborted" != [Yy1]* ]]; then
# Mark ISO as prepared via magic byte
if ! printf '\x16' | dd of="$iso" bs=1 seek=0 count=1 conv=notrunc status=none; then
error "Failed to set magic byte in ISO file: $iso" && return 1
fi
fi
rm -f "$STORAGE/windows.old"
rm -f "$STORAGE/windows.boot"
rm -f "$STORAGE/windows.mode"
cp /run/version "$STORAGE/windows.ver"
echo "$BASE" > "$STORAGE/windows.base"
if [[ "${PLATFORM,,}" == "x64" ]]; then
if [[ "${BOOT_MODE,,}" == "windows_legacy" ]]; then
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
if [[ "${MACHINE,,}" != "q35" ]]; then
echo "$MACHINE" > "$STORAGE/windows.old"
fi
else
# Enable secure boot + TPM on manual installs as Win11 requires
if [[ "$MANUAL" == [Yy1]* ]] || [[ "$aborted" == [Yy1]* ]]; then
if [[ "${DETECTED,,}" == "win11"* ]]; then
BOOT_MODE="windows_secure"
echo "$BOOT_MODE" > "$STORAGE/windows.mode"
fi
fi
fi
fi
rm -rf "$TMP"
BOOT_INDEX=1
return 0
}
abortInstall() {
local iso="$1"
if [[ "$iso" != "$STORAGE/$BASE" ]]; then
if ! mv -f "$iso" "$STORAGE/$BASE"; then
error "Failed to move ISO file: $iso" && return 1
fi
fi
finishInstall "$STORAGE/$BASE" "Y" && return 0
return 1
}
detectCustom() {
CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname windows.iso -printf "%f\n" | head -n 1)
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1)
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname boot.iso -printf "%f\n" | head -n 1)
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1)
CUSTOM=""
local file size
if [ -z "$CUSTOM" ] && [[ "${VERSION,,}" != "http"* ]]; then
FN="${VERSION/\/storage\//}"
[[ "$FN" == "."* ]] && FN="${FN:1}"
CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname "$FN" -printf "%f\n" | head -n 1)
if [[ "${VERSION,,}" != "http"* ]]; then
file="${VERSION/\/storage\//}"
[[ "$file" == "."* ]] && file="${file:1}"
[[ "$file" == *"/"* ]] && file=""
[ -n "$file" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname "$file" -printf "%f\n" | head -n 1)
fi
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.iso -printf "%f\n" | head -n 1)
[ -z "$CUSTOM" ] && CUSTOM=$(find "$STORAGE" -maxdepth 1 -type f -iname custom.img -printf "%f\n" | head -n 1)
[ -z "$CUSTOM" ] && return 0
size="$(stat -c%s "$STORAGE/$CUSTOM")"
if [ -z "$size" ] || [[ "$size" == "0" ]]; then
CUSTOM=""
return 0
fi
file="windows.$size.iso"
[ -s "$STORAGE/$file" ] && CUSTOM="$file"
return 0
}
@ -183,15 +195,9 @@ getESD() {
local winCatalog size
case "${version,,}" in
"win11${PLATFORM,,}")
winCatalog="https://go.microsoft.com/fwlink?linkid=2156292"
;;
"win10${PLATFORM,,}")
winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361"
;;
*)
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
;;
"win11${PLATFORM,,}" ) winCatalog="https://go.microsoft.com/fwlink?linkid=2156292" ;;
"win10${PLATFORM,,}" ) winCatalog="https://go.microsoft.com/fwlink/?LinkId=841361" ;;
*) error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;;
esac
local msg="Downloading product information from Microsoft..."
@ -235,9 +241,9 @@ getESD() {
error "Failed to find Windows product in $eFile!" && return 1
fi
ESD_URL=$(xmllint --nonet --xpath '//FilePath' "$dir/$eFile" | sed -E -e 's/<[\/]?FilePath>//g')
ESD=$(xmllint --nonet --xpath '//FilePath' "$dir/$eFile" | sed -E -e 's/<[\/]?FilePath>//g')
if [ -z "$ESD_URL" ]; then
if [ -z "$ESD" ]; then
error "Failed to find ESD URL in $eFile!" && return 1
fi
@ -277,12 +283,36 @@ doMido() {
return 1
}
verifyFile() {
local iso="$1"
local check="$2"
local hash=""
[ -z "$check" ] && return 0
html "Verifying downloaded ISO..."
info "Calculating SHA256 checksum of the ISO file..."
hash=$(sha256sum "$iso" | cut -f1 -d' ')
if [[ "$hash" == "$check" ]]; then
info "Succesfully verified that the checksum was correct!" && return 0
fi
error "Invalid sha256 checksum: $hash , but expected value is: $check ! Please report this at $SUPPORT/issues"
rm -f "$iso"
return 1
}
downloadFile() {
local iso="$1"
local url="$2"
local desc="$3"
local rc progress domain
local sum="$3"
local desc="$4"
local rc progress domain dots
rm -f "$iso"
@ -296,8 +326,12 @@ downloadFile() {
local msg="Downloading $desc..."
domain=$(echo "$url" | awk -F/ '{print $3}')
domain=$(expr "$domain" : '.*\.\(.*\..*\)')
[[ "${domain,,}" != *"microsoft.com" ]] && msg="Downloading $desc from $domain..."
dots=$(echo "$domain" | tr -cd '.' | wc -c)
(( dots > 1 )) && domain=$(expr "$domain" : '.*\.\(.*\..*\)')
if [ -n "$domain" ] && [[ "${domain,,}" != *"microsoft.com" ]]; then
msg="Downloading $desc from $domain..."
fi
info "$msg" && html "$msg"
/run/progress.sh "$iso" "Downloading $desc ([P])..." &
@ -308,13 +342,16 @@ downloadFile() {
if (( rc == 0 )) && [ -f "$iso" ]; then
if [ "$(stat -c%s "$iso")" -gt 100000000 ]; then
if [[ "$VERIFY" == [Yy1]* ]] && [ -n "$sum" ]; then
! verifyFile "$iso" "$sum" && return 1
fi
html "Download finished successfully..." && return 0
fi
fi
rm -f "$iso"
error "Failed to download $url , reason: $rc"
rm -f "$iso"
return 1
}
@ -323,25 +360,19 @@ downloadImage() {
local iso="$1"
local version="$2"
local tried="n"
local url desc
local url sum desc
if [[ "${version,,}" == "http"* ]]; then
desc=$(getName "$BASE" "$BASE")
downloadFile "$iso" "$version" "$desc" && return 0
desc=$(fromFile "$BASE")
downloadFile "$iso" "$version" "" "$desc" && return 0
return 1
fi
if ! validVersion "$version"; then
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
fi
if [[ "${PLATFORM,,}" == "x64" ]]; then
desc=$(printVersion "$version" "Windows")
else
desc=$(printVersion "$version" "Windows for ${PLATFORM}")
fi
desc=$(printVersion "$version" "")
if [[ "${PLATFORM,,}" == "x64" ]]; then
if isMido "$version"; then
@ -361,37 +392,26 @@ downloadImage() {
if getESD "$TMP/esd" "$version"; then
ISO="$TMP/$version.esd"
downloadFile "$ISO" "$ESD_URL" "$desc" && return 0
downloadFile "$ISO" "$ESD" "" "$desc" && return 0
ISO="$TMP/$BASE"
fi
fi
url=$(getLink "$version")
for ((i=1;i<=MIRRORS;i++)); do
if [ -n "$url" ]; then
url=$(getLink "$i" "$version")
if [[ "$tried" != "n" ]]; then
info "Failed to download $desc from Microsoft, will try another mirror now..."
if [ -n "$url" ]; then
if [[ "$tried" != "n" ]]; then
info "Failed to download $desc, will try another mirror now..."
fi
tried="y"
sum=$(getHash "$i" "$version")
downloadFile "$iso" "$url" "$sum" "$desc" && return 0
fi
tried="y"
downloadFile "$iso" "$url" "$desc" && return 0
fi
url=$(secondLink "$version")
if [ -n "$url" ]; then
if [[ "$tried" != "n" ]]; then
info "Failed to download $desc, will try another mirror now..."
fi
tried="y"
downloadFile "$iso" "$url" "$desc" && return 0
fi
done
return 1
}
@ -450,21 +470,21 @@ extractESD() {
error "Adding Windows Setup failed" && return ${retVal}
}
if [[ "${PLATFORM,,}" == "x64" ]]; then
LABEL="CCCOMA_X64FRE_EN-US_DV9"
else
LABEL="CPBA_A64FRE_EN-US_DV9"
fi
local msg="Extracting $desc image..."
info "$msg" && html "$msg"
local edition imageIndex imageEdition
case "${version,,}" in
"win11${PLATFORM,,}")
edition="11 pro"
;;
"win10${PLATFORM,,}")
edition="10 pro"
;;
*)
error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1
;;
"win11${PLATFORM,,}" ) edition="11 pro" ;;
"win10${PLATFORM,,}" ) edition="10 pro" ;;
*) error "Invalid VERSION specified, value \"$version\" is not recognized!" && return 1 ;;
esac
for (( imageIndex=4; imageIndex<=esdImageCount; imageIndex++ )); do
@ -485,11 +505,14 @@ extractImage() {
local iso="$1"
local dir="$2"
local version="$3"
local desc="downloaded ISO"
local desc="local ISO"
local size size_gb space space_gb
if [[ "$EXTERNAL" != [Yy1]* ]] && [ -z "$CUSTOM" ]; then
desc=$(printVersion "$version" "downloaded ISO")
if [ -z "$CUSTOM" ]; then
desc="downloaded ISO"
if [[ "$version" != "http"* ]]; then
desc=$(printVersion "$version" "$desc")
fi
fi
if [[ "${iso,,}" == *".esd" ]]; then
@ -498,7 +521,6 @@ extractImage() {
fi
local msg="Extracting $desc image..."
[ -n "$CUSTOM" ] && msg="Extracting local ISO image..."
info "$msg" && html "$msg"
rm -rf "$dir"
@ -523,56 +545,119 @@ extractImage() {
error "Failed to extract ISO file: $iso" && return 1
fi
LABEL=$(isoinfo -d -i "$iso" | sed -n 's/Volume id: //p')
return 0
}
setXML() {
[[ "$MANUAL" == [Yy1]* ]] && return 0
local file="$STORAGE/custom.xml"
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
file="/run/assets/custom.xml"
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
file="$1"
[ -z "$file" ] && file="/run/assets/$DETECTED.xml"
[ -f "$file" ] && [ -s "$file" ] && XML="$file" && return 0
return 1
}
selectVersion() {
local tag="$1"
local xml="$2"
local id find name prefer
name=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$xml")
[[ "$name" == *"Operating System"* ]] && name=""
[ -z "$name" ] && return 0
id=$(fromName "$name")
[ -z "$id" ] && info "Unknown ${tag,,}: '$name'" && return 0
prefer="$id-enterprise"
[ -f "/run/assets/$prefer.xml" ] && find=$(printEdition "$prefer" "") || find=""
if [ -n "$find" ] && [[ "${xml,,}" == *"<${tag,,}>${find,,}</${tag,,}>"* ]]; then
echo "$prefer" && return 0
fi
prefer="$id-ultimate"
[ -f "/run/assets/$prefer.xml" ] && find=$(printEdition "$prefer" "") || find=""
if [ -n "$find" ] && [[ "${xml,,}" == *"<${tag,,}>${find,,}</${tag,,}>"* ]]; then
echo "$prefer" && return 0
fi
prefer="$id"
[ -f "/run/assets/$prefer.xml" ] && find=$(printEdition "$prefer" "") || find=""
if [ -n "$find" ] && [[ "${xml,,}" == *"<${tag,,}>${find,,}</${tag,,}>"* ]]; then
echo "$prefer" && return 0
fi
prefer=$(getVersion "$name")
echo "$prefer"
return 0
}
detectVersion() {
local xml="$1"
local id=""
id=$(selectVersion "DISPLAYNAME" "$xml")
[ -n "$id" ] && echo "$id" && return 0
id=$(selectVersion "PRODUCTNAME" "$xml")
[ -n "$id" ] && echo "$id" && return 0
id=$(selectVersion "NAME" "$xml")
[ -n "$id" ] && echo "$id" && return 0
return 0
}
detectImage() {
XML=""
local dsc
local dir="$1"
local version="$2"
local desc msg
XML=""
if [ -n "$CUSTOM" ]; then
DETECTED=""
else
if [ -z "$DETECTED" ] && [[ "$EXTERNAL" != [Yy1]* ]]; then
DETECTED="$VERSION"
if [ -z "$DETECTED" ] && [[ "${version,,}" != "http"* ]]; then
DETECTED="$version"
fi
fi
if [ -n "$DETECTED" ]; then
if [ -f "/run/assets/$DETECTED.xml" ]; then
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
return 0
fi
[[ "${DETECTED,,}" == "winxp"* ]] && return 0
if [[ "${DETECTED,,}" != "winxp"* ]]; then
dsc=$(printVersion "$DETECTED" "$DETECTED")
warn "got $dsc, but no matching file called $DETECTED.xml exists, $FB."
fi
setXML "" && return 0
desc=$(printEdition "$DETECTED" "this version")
warn "the answer file for $desc was not found ($DETECTED.xml), $FB."
return 0
fi
info "Detecting Windows version from ISO image..."
info "Detecting version from ISO image..."
if [[ "${PLATFORM,,}" == "x64" ]]; then
if [ -f "$dir/WIN51" ] || [ -f "$dir/SETUPXP.HTM" ]; then
if [ -d "$dir/AMD64" ]; then
DETECTED="winxpx64"
else
DETECTED="winxpx86"
fi
dsc=$(printVersion "$DETECTED" "$DETECTED")
info "Detected: $dsc"
return 0
fi
if [ -f "$dir/WIN51" ] || [ -f "$dir/SETUPXP.HTM" ]; then
[ -d "$dir/AMD64" ] && DETECTED="winxpx64" || DETECTED="winxpx86"
desc=$(printEdition "$DETECTED" "Windows XP")
info "Detected: $desc"
return 0
fi
local src loc tag result name name2 desc
local src loc info
src=$(find "$dir" -maxdepth 1 -type d -iname sources | head -n 1)
if [ ! -d "$src" ]; then
@ -588,33 +673,24 @@ detectImage() {
warn "failed to locate 'install.wim' or 'install.esd' in ISO image, $FB" && return 1
fi
tag="DISPLAYNAME"
result=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
name=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result")
DETECTED=$(getVersion "$name")
info=$(wimlib-imagex info -xml "$loc" | tr -d '\000')
DETECTED=$(detectVersion "$info")
if [ -z "$DETECTED" ]; then
tag="PRODUCTNAME"
name2=$(sed -n "/$tag/{s/.*<$tag>\(.*\)<\/$tag>.*/\1/;p}" <<< "$result")
[ -z "$name" ] && name="$name2"
DETECTED=$(getVersion "$name2")
msg="Failed to determine Windows version from image"
setXML "" && info "${msg}!" || warn "${msg}, $FB"
return 0
fi
if [ -z "$DETECTED" ]; then
warn "failed to determine Windows version from string '$name', $FB" && return 0
fi
desc=$(printEdition "$DETECTED" "$DETECTED")
desc=$(printVersion "$DETECTED" "$DETECTED")
info "Detected: $desc"
setXML "" && return 0
if [ -f "/run/assets/$DETECTED.xml" ]; then
[[ "$MANUAL" != [Yy1]* ]] && XML="$DETECTED.xml"
info "Detected: $desc"
else
warn "detected $desc, but no matching file called $DETECTED.xml exists, $FB."
fi
msg="the answer file for $desc was not found ($DETECTED.xml)"
local fallback="/run/assets/${DETECTED%%-*}.xml"
setXML "$fallback" && warn "${msg}." || warn "${msg}, $FB."
return 0
}
@ -622,45 +698,41 @@ prepareImage() {
local iso="$1"
local dir="$2"
local missing
case "${DETECTED,,}" in
"winxp"* )
BOOT_MODE="windows_legacy"
prepareXP "$iso" "$dir" && return 0
error "Failed to prepare Windows XP ISO!" && return 1
;;
"winvista"* | "win7"* | "win2008"* )
BOOT_MODE="windows_legacy" ;;
esac
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
if [[ "${DETECTED,,}" != "winxp"* ]] && [[ "${DETECTED,,}" != "win2008"* ]]; then
if [[ "${DETECTED,,}" != "winvista"* ]] && [[ "${DETECTED,,}" != "win7"* ]]; then
if [ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ]; then
return 0
fi
[ -f "$dir/$ETFS" ] && [ -f "$dir/$EFISYS" ] && return 0
if [ ! -f "$dir/$ETFS" ]; then
warn "failed to locate file 'etfsboot.com' in ISO image, falling back to legacy boot!"
else
warn "failed to locate file 'efisys_noprompt.bin' in ISO image, falling back to legacy boot!"
fi
missing=$(basename "$dir/$EFISYS")
[ ! -f "$dir/$ETFS" ] && missing=$(basename "$dir/$ETFS")
warn "failed to locate file '${missing,,}' in ISO image!"
fi
fi
[[ "${PLATFORM,,}" == "arm64" ]] && return 1
BOOT_MODE="windows_legacy"
fi
[[ "${PLATFORM,,}" == "arm64" ]] && return 1
prepareLegacy "$iso" "$dir" && return 0
if [[ "${DETECTED,,}" == "winxp"* ]]; then
if ! prepareXP "$iso" "$dir"; then
error "Failed to prepare Windows XP ISO!" && return 1
fi
else
if ! prepareLegacy "$iso" "$dir"; then
error "Failed to prepare Windows ISO!" && return 1
fi
fi
return 0
error "Failed to extract boot image from ISO!"
return 1
}
updateImage() {
local iso="$1"
local dir="$2"
local asset="/run/assets/$3"
local asset="$3"
local path src loc xml index result
[ ! -s "$asset" ] || [ ! -f "$asset" ] && return 0
@ -694,17 +766,20 @@ updateImage() {
fi
if ! wimlib-imagex update "$loc" "$index" --command "add $asset /autounattend.xml" > /dev/null; then
warn "failed to add $xml to ISO image, $FB" && return 1
warn "failed to add answer file ($xml) to ISO image, $FB" && return 1
fi
return 0
}
copyOEM() {
local dir="$1"
local folder="$STORAGE/oem"
local folder="/oem"
local src
[ ! -d "$folder" ] && folder="/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/shared/oem"
[ ! -d "$folder" ] && folder="$STORAGE/shared/OEM"
@ -734,12 +809,10 @@ buildImage() {
local dir="$1"
local failed="N"
local cat="BOOT.CAT"
local label="${BASE%.*}"
local log="/run/shm/iso.log"
local size size_gb space space_gb desc
local out="$TMP/${BASE%.*}.tmp"
label="${label::30}"
local out="$TMP/$label.tmp"
rm -f "$out"
desc=$(printVersion "$DETECTED" "ISO")
@ -756,9 +829,11 @@ buildImage() {
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
fi
[ -z "$LABEL" ] && LABEL="${BASE%%.*}"
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 4 -J -l -D -N -joliet-long -relaxed-filenames -V "${LABEL::30}" \
-udf -boot-info-table -eltorito-alt-boot -eltorito-boot "$EFISYS" -no-emul-boot -allow-limited-size -quiet "$dir" 2> "$log"; then
failed="Y"
fi
@ -767,7 +842,7 @@ buildImage() {
if [[ "${DETECTED,,}" != "winxp"* ]]; then
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "$label" \
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -c "$cat" -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "${LABEL::30}" \
-udf -allow-limited-size -quiet "$dir" 2> "$log"; then
failed="Y"
fi
@ -775,7 +850,7 @@ buildImage() {
else
if ! genisoimage -o "$out" -b "$ETFS" -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -c "$cat" -iso-level 2 -J -l -D -N -joliet-long \
-relaxed-filenames -V "$label" -quiet "$dir" 2> "$log"; then
-relaxed-filenames -V "${LABEL::30}" -quiet "$dir" 2> "$log"; then
failed="Y"
fi
@ -872,7 +947,7 @@ if ! extractImage "$ISO" "$DIR" "$VERSION"; then
exit 62
fi
if ! detectImage "$DIR"; then
if ! detectImage "$DIR" "$VERSION"; then
abortInstall "$ISO" && return 0
exit 60
fi
@ -888,7 +963,8 @@ if ! updateImage "$ISO" "$DIR" "$XML"; then
fi
if ! rm -f "$ISO" 2> /dev/null; then
BASE="windows.iso"
size="$(stat -c%s "$ISO")"
BASE="windows.$size.iso"
ISO="$STORAGE/$BASE"
rm -f "$ISO"
fi

View File

@ -388,7 +388,7 @@ consumer_download() {
# Filter for 64-bit ISO download URL
# sed: HTML decode "&" character
# tr: Filter for only alphanumerics or punctuation
iso_download_link="$(echo "$iso_download_link_html" | grep -o "https://software.download.prss.microsoft.com.*IsoX64" | cut -d '"' -f 1 | sed 's/&amp;/\&/g' | tr -cd '[:alnum:][:punct:]' | head -c 512)"
iso_download_link="$(echo "$iso_download_link_html" | grep -o "https://software.download.prss.microsoft.com.*IsoX64" | cut -d '"' -f 1 | sed 's/&amp;/\&/g' | tr -cd '[:alnum:][:punct:]')"
if ! [ "$iso_download_link" ]; then
# This should only happen if there's been some change to the download endpoint web address

View File

@ -28,7 +28,7 @@ boot() {
[ -f "$QEMU_END" ] && return 0
if [ -s "$QEMU_PTY" ]; then
if grep -iq " hard" "$QEMU_PTY"; then
if [ "$(stat -c%s "$QEMU_PTY")" -gt 7 ]; then
info "Windows started succesfully, visit http://localhost:8006/ to view the screen..."
return 0
fi
@ -93,7 +93,9 @@ finish() {
pid="/var/run/tpm.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
fKill "wsdd"
pid="/var/run/wsdd.pid"
[ -s "$pid" ] && pKill "$(<"$pid")"
fKill "smbd"
closeNetwork

View File

@ -82,6 +82,7 @@ if [[ "$isXP" == [Yy1]* ]]; then
else
# Enable Web Service Discovery
wsdd -i "$interface" -p -n "$hostname" &
echo "$!" > /var/run/wsdd.pid
fi
return 0