mirror of
https://github.com/dockur/windows.git
synced 2026-01-22 19:03:04 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d86731dc24 | ||
|
|
bca8cb6817 | ||
|
|
d9c7983bb5 | ||
|
|
28f6e9c76b | ||
|
|
1081855571 | ||
|
|
57193b0f59 | ||
|
|
6825b6a45a | ||
|
|
c82725ec61 | ||
|
|
1f0cdc9bd1 | ||
|
|
9654a945fb | ||
|
|
a4fdfbdf91 | ||
|
|
b84a2b60a9 | ||
|
|
a5b4d7760d | ||
|
|
2c4094b0f7 | ||
|
|
66f595d84a | ||
|
|
6919e36aee | ||
|
|
658c84c55f | ||
|
|
3aa2f6e128 | ||
|
|
da8bbdcb47 | ||
|
|
d7fcf9a5da | ||
|
|
bb0a0b47b8 | ||
|
|
7120584548 | ||
|
|
e292d18d32 | ||
|
|
d92ac18210 | ||
|
|
243b3bb5d6 | ||
|
|
2cdb57a679 | ||
|
|
f1f6c640b9 | ||
|
|
86a766381e | ||
|
|
b39507c5a4 | ||
|
|
80dead1446 | ||
|
|
bc614fd233 |
21
Dockerfile
21
Dockerfile
@@ -1,7 +1,8 @@
|
|||||||
|
ARG VERSION_ARG="latest"
|
||||||
FROM scratch AS build-amd64
|
FROM scratch AS build-amd64
|
||||||
COPY --from=qemux/qemu-docker:6.05 / /
|
|
||||||
|
|
||||||
ARG VERSION_ARG="0.0"
|
COPY --from=qemux/qemu-docker:6.14 / /
|
||||||
|
|
||||||
ARG DEBCONF_NOWARNINGS="yes"
|
ARG DEBCONF_NOWARNINGS="yes"
|
||||||
ARG DEBIAN_FRONTEND="noninteractive"
|
ARG DEBIAN_FRONTEND="noninteractive"
|
||||||
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
|
ARG DEBCONF_NONINTERACTIVE_SEEN="true"
|
||||||
@@ -10,6 +11,7 @@ RUN set -eu && \
|
|||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get --no-install-recommends -y install \
|
apt-get --no-install-recommends -y install \
|
||||||
bc \
|
bc \
|
||||||
|
jq \
|
||||||
curl \
|
curl \
|
||||||
7zip \
|
7zip \
|
||||||
wsdd \
|
wsdd \
|
||||||
@@ -22,24 +24,25 @@ RUN set -eu && \
|
|||||||
libxml2-utils \
|
libxml2-utils \
|
||||||
libarchive-tools && \
|
libarchive-tools && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
echo "$VERSION_ARG" > /run/version && \
|
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
COPY --chmod=755 ./src /run/
|
COPY --chmod=755 ./src /run/
|
||||||
COPY --chmod=755 ./assets /run/assets
|
COPY --chmod=755 ./assets /run/assets
|
||||||
|
|
||||||
ADD --chmod=755 https://raw.githubusercontent.com/christgau/wsdd/v0.8/src/wsdd.py /usr/sbin/wsdd
|
ADD --chmod=664 https://github.com/qemus/virtiso-whql/releases/download/v1.9.44-0/virtio-win-1.9.44.tar.xz /drivers.txz
|
||||||
ADD --chmod=664 https://github.com/qemus/virtiso-whql/releases/download/v1.9.43-0/virtio-win-1.9.43.tar.xz /drivers.txz
|
|
||||||
|
|
||||||
FROM dockurr/windows-arm:2.20 AS build-arm64
|
FROM dockurr/windows-arm:${VERSION_ARG} AS build-arm64
|
||||||
FROM build-${TARGETARCH}
|
FROM build-${TARGETARCH}
|
||||||
|
|
||||||
EXPOSE 8006 3389
|
ARG VERSION_ARG="0.00"
|
||||||
VOLUME /storage
|
RUN echo "$VERSION_ARG" > /run/version
|
||||||
|
|
||||||
|
VOLUME /storage
|
||||||
|
EXPOSE 8006 3389
|
||||||
|
|
||||||
|
ENV VERSION="11"
|
||||||
ENV RAM_SIZE="4G"
|
ENV RAM_SIZE="4G"
|
||||||
ENV CPU_CORES="2"
|
ENV CPU_CORES="2"
|
||||||
ENV DISK_SIZE="64G"
|
ENV DISK_SIZE="64G"
|
||||||
ENV VERSION="win11"
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entry.sh"]
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ services:
|
|||||||
image: dockurr/windows
|
image: dockurr/windows
|
||||||
container_name: windows
|
container_name: windows
|
||||||
environment:
|
environment:
|
||||||
VERSION: "win11"
|
VERSION: "11"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
|
- /dev/net/tun
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: windows-pvc
|
name: windows-pvc
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
storage: 64Gi
|
storage: 64Gi
|
||||||
@@ -16,57 +17,61 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
name: windows
|
name: windows
|
||||||
spec:
|
spec:
|
||||||
terminationGracePeriodSeconds: 120 # the Kubernetes default is 30 seconds and it may be not enough
|
|
||||||
containers:
|
containers:
|
||||||
- name: windows
|
- name: windows
|
||||||
image: dockurr/windows
|
image: dockurr/windows
|
||||||
ports:
|
env:
|
||||||
- containerPort: 8006
|
- name: VERSION
|
||||||
protocol: TCP
|
value: "11"
|
||||||
- containerPort: 3389
|
- name: RAM_SIZE
|
||||||
protocol: TCP
|
value: "4G"
|
||||||
- containerPort: 3389
|
- name: CPU_CORES
|
||||||
protocol: UDP
|
value: "2"
|
||||||
securityContext:
|
- name: DISK_SIZE
|
||||||
privileged: true
|
value: "64G"
|
||||||
env:
|
ports:
|
||||||
- name: RAM_SIZE
|
- containerPort: 8006
|
||||||
value: 4G
|
- containerPort: 3389
|
||||||
- name: CPU_CORES
|
- containerPort: 3389
|
||||||
value: "2"
|
protocol: UDP
|
||||||
- name: DISK_SIZE
|
securityContext:
|
||||||
value: "64G"
|
capabilities:
|
||||||
volumeMounts:
|
add:
|
||||||
- mountPath: /storage
|
- NET_ADMIN
|
||||||
name: storage
|
privileged: true
|
||||||
- mountPath: /dev/kvm
|
volumeMounts:
|
||||||
name: dev-kvm
|
- mountPath: /storage
|
||||||
|
name: storage
|
||||||
|
- mountPath: /dev/kvm
|
||||||
|
name: dev-kvm
|
||||||
|
- mountPath: /dev/net/tun
|
||||||
|
name: dev-tun
|
||||||
|
terminationGracePeriodSeconds: 120
|
||||||
volumes:
|
volumes:
|
||||||
- name: storage
|
- name: storage
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: windows-pvc
|
claimName: windows-pvc
|
||||||
- name: dev-kvm
|
- hostPath:
|
||||||
hostPath:
|
path: /dev/kvm
|
||||||
path: /dev/kvm
|
name: dev-kvm
|
||||||
|
- hostPath:
|
||||||
|
path: /dev/net/tun
|
||||||
|
type: CharDevice
|
||||||
|
name: dev-tun
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: windows
|
name: windows
|
||||||
spec:
|
spec:
|
||||||
type: NodePort
|
ports:
|
||||||
|
- name: tcp-8006
|
||||||
|
port: 8006
|
||||||
|
- name: tcp-3389
|
||||||
|
port: 3389
|
||||||
|
- name: udp-3389
|
||||||
|
port: 3389
|
||||||
|
protocol: UDP
|
||||||
selector:
|
selector:
|
||||||
name: windows
|
name: windows
|
||||||
ports:
|
type: NodePort
|
||||||
- name: tcp-8006
|
|
||||||
protocol: TCP
|
|
||||||
port: 8006
|
|
||||||
targetPort: 8006
|
|
||||||
- name: tcp-3389
|
|
||||||
protocol: TCP
|
|
||||||
port: 3389
|
|
||||||
targetPort: 3389
|
|
||||||
- name: udp-3389
|
|
||||||
protocol: UDP
|
|
||||||
port: 3389
|
|
||||||
targetPort: 3389
|
|
||||||
|
|||||||
80
readme.md
80
readme.md
@@ -34,9 +34,10 @@ services:
|
|||||||
image: dockurr/windows
|
image: dockurr/windows
|
||||||
container_name: windows
|
container_name: windows
|
||||||
environment:
|
environment:
|
||||||
VERSION: "win11"
|
VERSION: "11"
|
||||||
devices:
|
devices:
|
||||||
- /dev/kvm
|
- /dev/kvm
|
||||||
|
- /dev/net/tun
|
||||||
cap_add:
|
cap_add:
|
||||||
- NET_ADMIN
|
- NET_ADMIN
|
||||||
ports:
|
ports:
|
||||||
@@ -49,15 +50,25 @@ services:
|
|||||||
Via Docker CLI:
|
Via Docker CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm -p 8006:8006 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows
|
docker run -it --rm -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN --stop-timeout 120 dockurr/windows
|
||||||
```
|
```
|
||||||
|
|
||||||
Via Kubernetes:
|
Via Kubernetes:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl apply -f kubernetes.yml
|
kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/master/kubernetes.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compatibility ⚙️
|
||||||
|
|
||||||
|
| **Product** | **Platform** | |
|
||||||
|
|---|---|---|
|
||||||
|
| Docker Engine | Linux| ✅ |
|
||||||
|
| Docker Desktop | Linux | ❌ |
|
||||||
|
| Docker Desktop | macOS | ❌ |
|
||||||
|
| Docker Desktop | Windows 11 | ✅ |
|
||||||
|
| Docker Desktop | Windows 10 | ❌ |
|
||||||
|
|
||||||
## FAQ 💬
|
## FAQ 💬
|
||||||
|
|
||||||
### How do I use it?
|
### How do I use it?
|
||||||
@@ -74,38 +85,37 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
### How do I select the Windows version?
|
### How do I select the Windows version?
|
||||||
|
|
||||||
By default, Windows 11 will be installed. But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative Windows version to be downloaded:
|
By default, Windows 11 Pro will be installed. But you can add the `VERSION` environment variable to your compose file, in order to specify an alternative Windows version to be downloaded:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
VERSION: "win11"
|
VERSION: "11"
|
||||||
```
|
```
|
||||||
|
|
||||||
Select from the values below:
|
Select from the values below:
|
||||||
|
|
||||||
| **Value** | **Version** | **Size** |
|
| **Value** | **Version** | **Size** |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `win11` | Windows 11 Pro | 5.4 GB |
|
| `11` | Windows 11 Pro | 5.4 GB |
|
||||||
| `ltsc11` | Windows 11 LTSC | 4.2 GB |
|
| `11l` | Windows 11 LTSC | 4.2 GB |
|
||||||
| `win11e` | Windows 11 Enterprise | 5.8 GB |
|
| `11e` | Windows 11 Enterprise | 5.8 GB |
|
||||||
||||
|
||||
|
||||||
| `win10` | Windows 10 Pro | 5.7 GB |
|
| `10` | Windows 10 Pro | 5.7 GB |
|
||||||
| `ltsc10` | Windows 10 LTSC | 4.6 GB |
|
| `10l` | Windows 10 LTSC | 4.6 GB |
|
||||||
| `win10e` | Windows 10 Enterprise | 5.2 GB |
|
| `10e` | Windows 10 Enterprise | 5.2 GB |
|
||||||
||||
|
||||
|
||||||
| `win8` | Windows 8.1 Pro | 4.0 GB |
|
| `8e` | Windows 8.1 Enterprise | 3.7 GB |
|
||||||
| `win8e` | Windows 8.1 Enterprise | 3.7 GB |
|
| `7e` | Windows 7 Enterprise | 3.0 GB |
|
||||||
| `win7` | Windows 7 Enterprise | 3.0 GB |
|
| `ve` | Windows Vista Enterprise | 3.0 GB |
|
||||||
| `vista` | Windows Vista Enterprise | 3.0 GB |
|
| `xp` | Windows XP Professional | 0.6 GB |
|
||||||
| `winxp` | Windows XP Professional | 0.6 GB |
|
|
||||||
||||
|
||||
|
||||||
| `2025` | Windows Server 2025 | 5.0 GB |
|
| `2025` | Windows Server 2025 | 5.0 GB |
|
||||||
| `2022` | Windows Server 2022 | 4.7 GB |
|
| `2022` | Windows Server 2022 | 4.7 GB |
|
||||||
| `2019` | Windows Server 2019 | 5.3 GB |
|
| `2019` | Windows Server 2019 | 5.3 GB |
|
||||||
| `2016` | Windows Server 2016 | 6.5 GB |
|
| `2016` | Windows Server 2016 | 6.5 GB |
|
||||||
| `2012` | Windows Server 2012 | 4.3 GB |
|
| `2012` | Windows Server 2012 | 4.3 GB |
|
||||||
| `2008` | Windows Server 2008 | 3.0 GB |
|
| `2008` | Windows Server 2008 | 3.0 GB |
|
||||||
| `2003` | Windows Server 2003 | 0.6 GB |
|
| `2003` | Windows Server 2003 | 0.6 GB |
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> To install ARM64 versions of Windows use [dockur/windows-arm](https://github.com/dockur/windows-arm/).
|
> To install ARM64 versions of Windows use [dockur/windows-arm](https://github.com/dockur/windows-arm/).
|
||||||
@@ -135,7 +145,7 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
### How do I share files with the host?
|
### 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`, which can be binded to any folder on your host via the compose file:
|
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`, which can be bound to any folder on your host via the compose file:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
@@ -167,7 +177,9 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
### How do I run a script after installation?
|
### How do I run a script after installation?
|
||||||
|
|
||||||
To run your own script after installation, you can create a file called `install.bat` and place it in a folder together with any additional files it needs (software to be installed for example). Then bind that folder in your compose file like this:
|
To run your own script after installation, you can create a file called `install.bat` and place it in a folder together with any additional files it needs (software to be installed for example).
|
||||||
|
|
||||||
|
Then bind that folder in your compose file like this:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
@@ -220,7 +232,7 @@ kubectl apply -f kubernetes.yml
|
|||||||
LANGUAGE: "French"
|
LANGUAGE: "French"
|
||||||
```
|
```
|
||||||
|
|
||||||
You can choose between: 🇦🇪 Arabic, 🇧🇬 Bulgarian, 🇨🇳 Chinese, 🇭🇷 Croatian, 🇨🇿 Czech, 🇩🇰 Danish, 🇳🇱 Dutch, 🇬🇧 English, 🇪🇪 Estionian, 🇫🇮 Finnish, 🇫🇷 French, 🇩🇪 German, 🇬🇷 Greek, 🇮🇱 Hebrew, 🇭🇺 Hungarian, 🇮🇹 Italian, 🇯🇵 Japanese, 🇰🇷 Korean, 🇱🇻 Latvian, 🇱🇹 Lithuanian, 🇳🇴 Norwegian, 🇵🇱 Polish, 🇵🇹 Portuguese, 🇷🇴 Romanian, 🇷🇺 Russian, 🇷🇸 Serbian, 🇸🇰 Slovak, 🇸🇮 Slovenian, 🇪🇸 Spanish, 🇸🇪 Swedish, 🇹🇭 Thai, 🇹🇷 Turkish and 🇺🇦 Ukrainian.
|
You can choose between: 🇦🇪 Arabic, 🇧🇬 Bulgarian, 🇨🇳 Chinese, 🇭🇷 Croatian, 🇨🇿 Czech, 🇩🇰 Danish, 🇳🇱 Dutch, 🇬🇧 English, 🇪🇪 Estonian, 🇫🇮 Finnish, 🇫🇷 French, 🇩🇪 German, 🇬🇷 Greek, 🇮🇱 Hebrew, 🇭🇺 Hungarian, 🇮🇹 Italian, 🇯🇵 Japanese, 🇰🇷 Korean, 🇱🇻 Latvian, 🇱🇹 Lithuanian, 🇳🇴 Norwegian, 🇵🇱 Polish, 🇵🇹 Portuguese, 🇷🇴 Romanian, 🇷🇺 Russian, 🇷🇸 Serbian, 🇸🇰 Slovak, 🇸🇮 Slovenian, 🇪🇸 Spanish, 🇸🇪 Swedish, 🇹🇭 Thai, 🇹🇷 Turkish and 🇺🇦 Ukrainian.
|
||||||
|
|
||||||
### How do I select the keyboard layout?
|
### How do I select the keyboard layout?
|
||||||
|
|
||||||
@@ -340,24 +352,28 @@ kubectl apply -f kubernetes.yml
|
|||||||
|
|
||||||
### How do I verify if my system supports KVM?
|
### How do I verify if my system supports KVM?
|
||||||
|
|
||||||
To verify that your system supports KVM, run the following commands:
|
Only Linux and Windows 11 support KVM virtualization, macOS and Windows 10 do not unfortunately.
|
||||||
|
|
||||||
|
You can run the following commands in Linux to check your system:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install cpu-checker
|
sudo apt install cpu-checker
|
||||||
sudo kvm-ok
|
sudo kvm-ok
|
||||||
```
|
```
|
||||||
|
|
||||||
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, please check whether:
|
If you receive an error from `kvm-ok` indicating that KVM cannot be used, please check whether:
|
||||||
|
|
||||||
- the virtualization extensions (`Intel VT-x` or `AMD SVM`) are enabled in your BIOS.
|
- the virtualization extensions (`Intel VT-x` or `AMD SVM`) are enabled in your BIOS.
|
||||||
|
|
||||||
- you are running an operating system that supports them, like Linux or Windows 11 (macOS and Windows 10 do not unfortunately).
|
|
||||||
|
|
||||||
- you enabled "nested virtualization" if you are running the container inside a virtual machine.
|
- you enabled "nested virtualization" if you are running the container inside a virtual machine.
|
||||||
|
|
||||||
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
|
||||||
|
|
||||||
If you didn't receive any error from `kvm-ok` at all, but the container still complains that `/dev/kvm` is missing, it might help to add `privileged: true` to your compose file (or `--privileged` to your `run` command), to rule out any permission issue.
|
If you do not receive any error from `kvm-ok` but the container still complains about KVM, please check whether:
|
||||||
|
|
||||||
|
- you are not using "Docker Desktop for Linux" as it does not support KVM, instead make use of Docker Engine directly.
|
||||||
|
|
||||||
|
- it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue.
|
||||||
|
|
||||||
### How do I run macOS in a container?
|
### How do I run macOS in a container?
|
||||||
|
|
||||||
|
|||||||
826
src/define.sh
826
src/define.sh
File diff suppressed because it is too large
Load Diff
@@ -120,6 +120,7 @@ finishInstall() {
|
|||||||
|
|
||||||
rm -f "$STORAGE/windows.old"
|
rm -f "$STORAGE/windows.old"
|
||||||
rm -f "$STORAGE/windows.vga"
|
rm -f "$STORAGE/windows.vga"
|
||||||
|
rm -f "$STORAGE/windows.args"
|
||||||
rm -f "$STORAGE/windows.base"
|
rm -f "$STORAGE/windows.base"
|
||||||
rm -f "$STORAGE/windows.boot"
|
rm -f "$STORAGE/windows.boot"
|
||||||
rm -f "$STORAGE/windows.mode"
|
rm -f "$STORAGE/windows.mode"
|
||||||
@@ -156,6 +157,11 @@ finishInstall() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${ARGS:-}" ]; then
|
||||||
|
ARGUMENTS="$ARGS ${ARGUMENTS:-}"
|
||||||
|
echo "$ARGS" > "$STORAGE/windows.args"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then
|
if [ -n "${DISK_TYPE:-}" ] && [[ "${DISK_TYPE:-}" != "scsi" ]]; then
|
||||||
echo "$DISK_TYPE" > "$STORAGE/windows.type"
|
echo "$DISK_TYPE" > "$STORAGE/windows.type"
|
||||||
fi
|
fi
|
||||||
@@ -614,11 +620,11 @@ updateXML() {
|
|||||||
local language="$2"
|
local language="$2"
|
||||||
local culture region user admin pass keyboard
|
local culture region user admin pass keyboard
|
||||||
|
|
||||||
[ -z "$YRES" ] && YRES="720"
|
[ -z "$HEIGHT" ] && HEIGHT="720"
|
||||||
[ -z "$XRES" ] && XRES="1280"
|
[ -z "$WIDTH" ] && WIDTH="1280"
|
||||||
|
|
||||||
sed -i "s/<VerticalResolution>1080<\/VerticalResolution>/<VerticalResolution>$YRES<\/VerticalResolution>/g" "$asset"
|
sed -i "s/<VerticalResolution>1080<\/VerticalResolution>/<VerticalResolution>$HEIGHT<\/VerticalResolution>/g" "$asset"
|
||||||
sed -i "s/<HorizontalResolution>1920<\/HorizontalResolution>/<HorizontalResolution>$XRES<\/HorizontalResolution>/g" "$asset"
|
sed -i "s/<HorizontalResolution>1920<\/HorizontalResolution>/<HorizontalResolution>$WIDTH<\/HorizontalResolution>/g" "$asset"
|
||||||
|
|
||||||
culture=$(getLanguage "$language" "culture")
|
culture=$(getLanguage "$language" "culture")
|
||||||
|
|
||||||
@@ -965,6 +971,11 @@ bootWindows() {
|
|||||||
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
|
if [ -f "$STORAGE/windows.args" ]; then
|
||||||
|
ARGS=$(<"$STORAGE/windows.args")
|
||||||
|
ARGUMENTS="$ARGS ${ARGUMENTS:-}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -s "$STORAGE/windows.type" ] && [ -f "$STORAGE/windows.type" ]; then
|
if [ -s "$STORAGE/windows.type" ] && [ -f "$STORAGE/windows.type" ]; then
|
||||||
[ -z "${DISK_TYPE:-}" ] && DISK_TYPE=$(<"$STORAGE/windows.type")
|
[ -z "${DISK_TYPE:-}" ] && DISK_TYPE=$(<"$STORAGE/windows.type")
|
||||||
fi
|
fi
|
||||||
|
|||||||
411
src/mido.sh
411
src/mido.sh
@@ -4,25 +4,26 @@ set -Eeuo pipefail
|
|||||||
handle_curl_error() {
|
handle_curl_error() {
|
||||||
|
|
||||||
local error_code="$1"
|
local error_code="$1"
|
||||||
|
local server_name="$2"
|
||||||
|
|
||||||
case "$error_code" in
|
case "$error_code" in
|
||||||
1) error "Unsupported protocol!" ;;
|
1) error "Unsupported protocol!" ;;
|
||||||
2) error "Failed to initialize curl!" ;;
|
2) error "Failed to initialize curl!" ;;
|
||||||
3) error "The URL format is malformed!" ;;
|
3) error "The URL format is malformed!" ;;
|
||||||
5) error "Failed to resolve address of proxy host!" ;;
|
5) error "Failed to resolve address of proxy host!" ;;
|
||||||
6) error "Failed to resolve Microsoft servers! Is there an Internet connection?" ;;
|
6) error "Failed to resolve $server_name servers! Is there an Internet connection?" ;;
|
||||||
7) error "Failed to contact Microsoft servers! Is there an Internet connection or is the server down?" ;;
|
7) error "Failed to contact $server_name servers! Is there an Internet connection or is the server down?" ;;
|
||||||
8) error "Microsoft servers returned a malformed HTTP response!" ;;
|
8) error "$server_name servers returned a malformed HTTP response!" ;;
|
||||||
16) error "A problem was detected in the HTTP2 framing layer!" ;;
|
16) error "A problem was detected in the HTTP2 framing layer!" ;;
|
||||||
22) error "Microsoft servers returned a failing HTTP status code!" ;;
|
22) error "$server_name servers returned a failing HTTP status code!" ;;
|
||||||
23) error "Failed at writing Windows media to disk! Out of disk space or permission error?" ;;
|
23) error "Failed at writing Windows media to disk! Out of disk space or permission error?" ;;
|
||||||
26) error "Failed to read Windows media from disk!" ;;
|
26) error "Failed to read Windows media from disk!" ;;
|
||||||
27) error "Ran out of memory during download!" ;;
|
27) error "Ran out of memory during download!" ;;
|
||||||
28) error "Connection timed out to Microsoft server!" ;;
|
28) error "Connection timed out to $server_name server!" ;;
|
||||||
35) error "SSL connection error from Microsoft server!" ;;
|
35) error "SSL connection error from $server_name server!" ;;
|
||||||
36) error "Failed to continue earlier download!" ;;
|
36) error "Failed to continue earlier download!" ;;
|
||||||
52) error "Received no data from the Microsoft server!" ;;
|
52) error "Received no data from the $server_name server!" ;;
|
||||||
63) error "Microsoft servers returned an unexpectedly large response!" ;;
|
63) error "$server_name servers returned an unexpectedly large response!" ;;
|
||||||
# POSIX defines exit statuses 1-125 as usable by us
|
# POSIX defines exit statuses 1-125 as usable by us
|
||||||
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02
|
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02
|
||||||
$((error_code <= 125)))
|
$((error_code <= 125)))
|
||||||
@@ -63,31 +64,33 @@ download_windows() {
|
|||||||
local lang="$2"
|
local lang="$2"
|
||||||
local desc="$3"
|
local desc="$3"
|
||||||
local sku_id=""
|
local sku_id=""
|
||||||
|
local sku_url=""
|
||||||
|
local iso_url=""
|
||||||
|
local iso_json=""
|
||||||
local language=""
|
local language=""
|
||||||
local session_id=""
|
local session_id=""
|
||||||
local user_agent=""
|
local user_agent=""
|
||||||
|
local download_type=""
|
||||||
local windows_version=""
|
local windows_version=""
|
||||||
local iso_download_link=""
|
local iso_download_link=""
|
||||||
|
local download_page_html=""
|
||||||
local product_edition_id=""
|
local product_edition_id=""
|
||||||
local iso_download_link_html=""
|
local language_skuid_json=""
|
||||||
local iso_download_page_html=""
|
local profile="606624d44113"
|
||||||
local language_skuid_table_html=""
|
|
||||||
|
|
||||||
case "${id,,}" in
|
|
||||||
"win11x64" ) windows_version="11" ;;
|
|
||||||
"win10x64" ) windows_version="10" ;;
|
|
||||||
"win81x64" ) windows_version="8" ;;
|
|
||||||
* ) error "Invalid VERSION specified, value \"$id\" is not recognized!" && return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
user_agent=$(get_agent)
|
user_agent=$(get_agent)
|
||||||
language=$(getLanguage "$lang" "name")
|
language=$(getLanguage "$lang" "name")
|
||||||
|
|
||||||
local url="https://www.microsoft.com/en-us/software-download/windows$windows_version"
|
case "${id,,}" in
|
||||||
case "$windows_version" in
|
"win11x64" ) windows_version="11" && download_type="1" ;;
|
||||||
8 | 10) url+="ISO";;
|
"win10x64" ) windows_version="10" && download_type="1" ;;
|
||||||
|
"win11arm64" ) windows_version="11arm64" && download_type="2" ;;
|
||||||
|
* ) error "Invalid VERSION specified, value \"$id\" is not recognized!" && return 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
local url="https://www.microsoft.com/en-us/software-download/windows$windows_version"
|
||||||
|
[[ "${id,,}" == "win10"* ]] && url+="ISO"
|
||||||
|
|
||||||
# uuidgen: For MacOS (installed by default) and other systems (e.g. with no /proc) that don't have a kernel interface for generating random UUIDs
|
# uuidgen: For MacOS (installed by default) and other systems (e.g. with no /proc) that don't have a kernel interface for generating random UUIDs
|
||||||
session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
|
session_id=$(cat /proc/sys/kernel/random/uuid 2> /dev/null || uuidgen --random)
|
||||||
|
|
||||||
@@ -96,44 +99,39 @@ download_windows() {
|
|||||||
# This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically
|
# This is the *only* request we make that Fido doesn't. Fido manually maintains a list of all the Windows release/edition product edition IDs in its script (see: $WindowsVersions array). This is helpful for downloading older releases (e.g. Windows 10 1909, 21H1, etc.) but we always want to get the newest release which is why we get this value dynamically
|
||||||
# Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden
|
# Also, keeping a "$WindowsVersions" array like Fido does would be way too much of a maintenance burden
|
||||||
# Remove "Accept" header that curl sends by default
|
# Remove "Accept" header that curl sends by default
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo " - Parsing download page: ${url}"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
|
||||||
iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --header "Accept:" --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
||||||
handle_curl_error $?
|
handle_curl_error "$?" "Microsoft"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: "
|
[[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting Product edition ID: "
|
||||||
# tr: Filter for only numerics to prevent HTTP parameter injection
|
product_edition_id=$(echo "$download_page_html" | grep -Eo '<option value="[0-9]+">Windows' | cut -d '"' -f 2 | head -n 1 | tr -cd '0-9' | head -c 16)
|
||||||
# head -c was recently added to POSIX: https://austingroupbugs.net/view.php?id=407
|
|
||||||
product_edition_id=$(echo "$iso_download_page_html" | grep -Eo '<option value="[0-9]+">Windows' | cut -d '"' -f 2 | head -n 1 | tr -cd '0-9' | head -c 16)
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "$product_edition_id"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "$product_edition_id"
|
||||||
|
|
||||||
|
if [ -z "$product_edition_id" ]; then
|
||||||
|
error "Product edition ID not found!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Permit Session ID: $session_id"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Permit Session ID: $session_id"
|
||||||
# Permit Session ID
|
# Permit Session ID
|
||||||
# "org_id" is always the same value
|
|
||||||
curl --silent --max-time 30 --output /dev/null --user-agent "$user_agent" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "https://vlscppe.microsoft.com/tags?org_id=y6jn8c31&session_id=$session_id" || {
|
curl --silent --max-time 30 --output /dev/null --user-agent "$user_agent" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "https://vlscppe.microsoft.com/tags?org_id=y6jn8c31&session_id=$session_id" || {
|
||||||
# This should only happen if there's been some change to how this API works
|
# This should only happen if there's been some change to how this API works
|
||||||
handle_curl_error $?
|
handle_curl_error "$?" "Microsoft"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract everything after the last slash
|
|
||||||
local url_segment_parameter="${url##*/}"
|
|
||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting language SKU ID: "
|
[[ "$DEBUG" == [Yy1]* ]] && echo -n "Getting language SKU ID: "
|
||||||
# Get language -> skuID association table
|
sku_url="https://www.microsoft.com/software-download-connector/api/getskuinformationbyproductedition?profile=$profile&ProductEditionId=$product_edition_id&SKU=undefined&friendlyFileName=undefined&Locale=en-US&sessionID=$session_id"
|
||||||
# SKU ID: This specifies the language of the ISO. We always use "English (United States)", however, the SKU for this changes with each Windows release
|
language_skuid_json=$(curl --silent --max-time 30 --request GET --user-agent "$user_agent" --referer "$url" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "$sku_url") || {
|
||||||
# We must make this request so our next one will be allowed
|
handle_curl_error "$?" "Microsoft"
|
||||||
# --data "" is required otherwise no "Content-Length" header will be sent causing HTTP response "411 Length Required"
|
|
||||||
language_skuid_table_html=$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --header "Accept:" --max-filesize 10K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=a8f8f489-4c7f-463a-9ca6-5cff94d8d041&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=getskuinformationbyproductedition&sessionId=$session_id&productEditionId=$product_edition_id&sdVersion=2") || {
|
|
||||||
handle_curl_error $?
|
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# tr: Filter for only alphanumerics or "-" to prevent HTTP parameter injection
|
{ sku_id=$(echo "$language_skuid_json" | jq --arg LANG "$language" -r '.Skus[] | select(.Language==$LANG).Id') 2>/dev/null; rc=$?; } || :
|
||||||
sku_id=$(echo "$language_skuid_table_html" | grep -m 1 ">${language}<" | sed 's/"//g' | cut -d ',' -f 1 | cut -d ':' -f 2 | tr -cd '[:alnum:]-' | head -c 16)
|
|
||||||
|
|
||||||
if [ -z "$sku_id" ]; then
|
if [ -z "$sku_id" ] || [[ "${sku_id,,}" == "null" ]] || (( rc != 0 )); then
|
||||||
language=$(getLanguage "$lang" "desc")
|
language=$(getLanguage "$lang" "desc")
|
||||||
error "No download in the $language language available for $desc!"
|
error "No download in the $language language available for $desc!"
|
||||||
return 1
|
return 1
|
||||||
@@ -144,28 +142,31 @@ download_windows() {
|
|||||||
|
|
||||||
# Get ISO download link
|
# Get ISO download link
|
||||||
# If any request is going to be blocked by Microsoft it's always this last one (the previous requests always seem to succeed)
|
# If any request is going to be blocked by Microsoft it's always this last one (the previous requests always seem to succeed)
|
||||||
# --referer: Required by Microsoft servers to allow request
|
|
||||||
iso_download_link_html=$(curl --silent --max-time 30 --request POST --user-agent "$user_agent" --data "" --referer "$url" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "https://www.microsoft.com/en-US/api/controls/contentinclude/html?pageId=6e2a1789-ef16-4f27-a296-74ef7ef5d96b&host=www.microsoft.com&segments=software-download,$url_segment_parameter&query=&action=GetProductDownloadLinksBySku&sessionId=$session_id&skuId=$sku_id&language=English&sdVersion=2")
|
|
||||||
|
|
||||||
if ! [ "$iso_download_link_html" ]; then
|
iso_url="https://www.microsoft.com/software-download-connector/api/GetProductDownloadLinksBySku?profile=$profile&ProductEditionId=undefined&SKU=$sku_id&friendlyFileName=undefined&Locale=en-US&sessionID=$session_id"
|
||||||
|
iso_json=$(curl --silent --max-time 30 --request GET --user-agent "$user_agent" --referer "$url" --header "Accept:" --max-filesize 100K --fail --proto =https --tlsv1.2 --http1.1 -- "$iso_url")
|
||||||
|
|
||||||
|
if ! [ "$iso_json" ]; then
|
||||||
# This should only happen if there's been some change to how this API works
|
# This should only happen if there's been some change to how this API works
|
||||||
error "Microsoft servers gave us an empty response to our request for an automated download."
|
error "Microsoft servers gave us an empty response to our request for an automated download."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$iso_download_link_html" | grep -q "We are unable to complete your request at this time."; then
|
if echo "$iso_json" | grep -q "Sentinel marked this request as rejected."; then
|
||||||
error "Microsoft blocked the automated download request based on your IP address."
|
error "Microsoft blocked the automated download request based on your IP address."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Filter for 64-bit ISO download URL
|
if echo "$iso_json" | grep -q "We are unable to complete your request at this time."; then
|
||||||
# sed: HTML decode "&" character
|
error "Microsoft blocked the automated download request based on your IP address."
|
||||||
# tr: Filter for only alphanumerics or punctuation
|
return 1
|
||||||
iso_download_link=$(echo "$iso_download_link_html" | grep -o "https://software.download.prss.microsoft.com.*IsoX64" | cut -d '"' -f 1 | sed 's/&/\&/g' | tr -cd '[:alnum:][:punct:]')
|
fi
|
||||||
|
|
||||||
if ! [ "$iso_download_link" ]; then
|
{ iso_download_link=$(echo "$iso_json" | jq --argjson TYPE "$download_type" -r '.ProductDownloadOptions[] | select(.DownloadType==$TYPE).Uri') 2>/dev/null; rc=$?; } || :
|
||||||
# This should only happen if there's been some change to the download endpoint web address
|
|
||||||
|
if [ -z "$iso_download_link" ] || [[ "${iso_download_link,,}" == "null" ]] || (( rc != 0 )); then
|
||||||
error "Microsoft servers gave us no download link to our request for an automated download!"
|
error "Microsoft servers gave us no download link to our request for an automated download!"
|
||||||
|
info "Response: $iso_json"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -229,7 +230,7 @@ download_windows_eval() {
|
|||||||
|
|
||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${url}"
|
||||||
iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
iso_download_page_html=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
||||||
handle_curl_error $?
|
handle_curl_error "$?" "Microsoft"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,11 +284,11 @@ download_windows_eval() {
|
|||||||
[[ "$DEBUG" == [Yy1]* ]] && echo "Found download link: $iso_download_link"
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Found download link: $iso_download_link"
|
||||||
|
|
||||||
# Follow redirect so proceeding log message is useful
|
# Follow redirect so proceeding log message is useful
|
||||||
# This is a request we make this Fido doesn't
|
# This is a request we make that Fido doesn't
|
||||||
# We don't need to set "--max-filesize" here because this is a HEAD request and the output is to /dev/null anyway
|
|
||||||
iso_download_link=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --output /dev/null --silent --write-out "%{url_effective}" --head --fail --proto =https --tlsv1.2 --http1.1 -- "$iso_download_link") || {
|
iso_download_link=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --output /dev/null --silent --write-out "%{url_effective}" --head --fail --proto =https --tlsv1.2 --http1.1 -- "$iso_download_link") || {
|
||||||
# This should only happen if the Microsoft servers are down
|
# This should only happen if the Microsoft servers are down
|
||||||
handle_curl_error $?
|
handle_curl_error "$?" "Microsoft"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@ getWindows() {
|
|||||||
language=$(getLanguage "$lang" "desc")
|
language=$(getLanguage "$lang" "desc")
|
||||||
edition=$(printEdition "$version" "$desc")
|
edition=$(printEdition "$version" "$desc")
|
||||||
|
|
||||||
local msg="Requesting $desc from Microsoft server..."
|
local msg="Requesting $desc from the Microsoft servers..."
|
||||||
info "$msg" && html "$msg"
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
case "${version,,}" in
|
case "${version,,}" in
|
||||||
@@ -317,6 +318,7 @@ getWindows() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "${version,,}" in
|
case "${version,,}" in
|
||||||
|
"win11${PLATFORM,,}" ) ;;
|
||||||
"win11${PLATFORM,,}-enterprise-iot"* ) ;;
|
"win11${PLATFORM,,}-enterprise-iot"* ) ;;
|
||||||
"win11${PLATFORM,,}-enterprise-ltsc"* ) ;;
|
"win11${PLATFORM,,}-enterprise-ltsc"* ) ;;
|
||||||
* )
|
* )
|
||||||
@@ -327,7 +329,7 @@ getWindows() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "${version,,}" in
|
case "${version,,}" in
|
||||||
"win81${PLATFORM,,}" | "win10${PLATFORM,,}" | "win11${PLATFORM,,}" )
|
"win10${PLATFORM,,}" | "win11${PLATFORM,,}" )
|
||||||
download_windows "$version" "$lang" "$edition" && return 0
|
download_windows "$version" "$lang" "$edition" && return 0
|
||||||
;;
|
;;
|
||||||
"win11${PLATFORM,,}-enterprise"* | "win10${PLATFORM,,}-enterprise"* )
|
"win11${PLATFORM,,}-enterprise"* | "win10${PLATFORM,,}-enterprise"* )
|
||||||
@@ -427,6 +429,243 @@ getCatalog() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMG() {
|
||||||
|
|
||||||
|
local version="$1"
|
||||||
|
local lang="$2"
|
||||||
|
local desc="$3"
|
||||||
|
|
||||||
|
local locale=""
|
||||||
|
local culture=""
|
||||||
|
local language=""
|
||||||
|
local user_agent=""
|
||||||
|
|
||||||
|
user_agent=$(get_agent)
|
||||||
|
language=$(getLanguage "$lang" "desc")
|
||||||
|
culture=$(getLanguage "$lang" "culture")
|
||||||
|
|
||||||
|
local msg="Requesting download link from massgrave.dev..."
|
||||||
|
info "$msg" && html "$msg"
|
||||||
|
|
||||||
|
local pattern=""
|
||||||
|
local locale="${culture,,}"
|
||||||
|
local platform="${PLATFORM,,}"
|
||||||
|
local url="https://massgrave.dev/"
|
||||||
|
|
||||||
|
if [[ "${PLATFORM,,}" != "arm64" ]]; then
|
||||||
|
|
||||||
|
case "${version,,}" in
|
||||||
|
"win11${PLATFORM,,}" )
|
||||||
|
url+="windows_11_links"
|
||||||
|
pattern="consumer"
|
||||||
|
;;
|
||||||
|
"win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval" )
|
||||||
|
url+="windows_11_links"
|
||||||
|
pattern="business"
|
||||||
|
;;
|
||||||
|
"win11${PLATFORM,,}-ltsc" | "win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||||
|
url+="windows_ltsc_links"
|
||||||
|
pattern="11_enterprise_ltsc"
|
||||||
|
;;
|
||||||
|
"win11${PLATFORM,,}-iot" | "win11${PLATFORM,,}-enterprise-iot-eval" )
|
||||||
|
url+="windows_ltsc_links"
|
||||||
|
pattern="11_iot"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}" )
|
||||||
|
url+="windows_10_links"
|
||||||
|
pattern="consumer"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}-enterprise" | "win10${PLATFORM,,}-enterprise-eval" )
|
||||||
|
url+="windows_10_links"
|
||||||
|
pattern="business"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||||
|
url+="windows_ltsc_links"
|
||||||
|
pattern="10_enterprise_ltsc"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}-iot" | "win10${PLATFORM,,}-enterprise-iot-eval" )
|
||||||
|
url+="windows_ltsc_links"
|
||||||
|
pattern="10_iot"
|
||||||
|
;;
|
||||||
|
"win81${PLATFORM,,}-enterprise" | "win81${PLATFORM,,}-enterprise-eval" )
|
||||||
|
url+="windows_8.1_links"
|
||||||
|
pattern="8.1_enterprise"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
[[ "$locale" == "sr" ]] && locale="sr-latn"
|
||||||
|
;;
|
||||||
|
"win2025" | "win2025-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2025"
|
||||||
|
;;
|
||||||
|
"win2022" | "win2022-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2022"
|
||||||
|
;;
|
||||||
|
"win2019" | "win2019-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2019"
|
||||||
|
;;
|
||||||
|
"win2016" | "win2016-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2016"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
[[ "$locale" == "hk" ]] && locale="ct"
|
||||||
|
[[ "$locale" == "tw" ]] && locale="ct"
|
||||||
|
;;
|
||||||
|
"win2012r2" | "win2012r2-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2012_r2"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"win2008r2" | "win2008r2-eval" )
|
||||||
|
url+="windows_server_links"
|
||||||
|
pattern="server_2008_r2"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"win7x64" | "win7x64-enterprise" )
|
||||||
|
url+="windows_7_links"
|
||||||
|
pattern="enterprise"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"win7x64-ultimate" )
|
||||||
|
url+="windows_7_links"
|
||||||
|
pattern="ultimate"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"win7x86" | "win7x86-enterprise" )
|
||||||
|
platform="x86"
|
||||||
|
url+="windows_7_links"
|
||||||
|
pattern="enterprise"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"win7x86-ultimate" )
|
||||||
|
platform="x86"
|
||||||
|
url+="windows_7_links"
|
||||||
|
pattern="ultimate"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"winvistax64" | "winvistax64-enterprise" )
|
||||||
|
url+="windows_vista_links"
|
||||||
|
pattern="enterprise"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"winvistax64-ultimate" )
|
||||||
|
url+="windows_vista_links"
|
||||||
|
pattern="sp2"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"winvistax86" | "winvistax86-enterprise" )
|
||||||
|
platform="x86"
|
||||||
|
url+="windows_vista_links"
|
||||||
|
pattern="enterprise"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"winvistax86-ultimate" )
|
||||||
|
platform="x86"
|
||||||
|
url+="windows_vista_links"
|
||||||
|
pattern="sp2"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
"winxpx86" )
|
||||||
|
platform="x86"
|
||||||
|
url+="windows_xp_links"
|
||||||
|
pattern="xp"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
[[ "$locale" == "pt" ]] && locale="pt-br"
|
||||||
|
[[ "$locale" == "pp" ]] && locale="pt-pt"
|
||||||
|
[[ "$locale" == "cn" ]] && locale="zh-hans"
|
||||||
|
[[ "$locale" == "hk" ]] && locale="zh-hk"
|
||||||
|
[[ "$locale" == "tw" ]] && locale="zh-tw"
|
||||||
|
;;
|
||||||
|
"winxpx64" )
|
||||||
|
url+="windows_xp_links"
|
||||||
|
pattern="xp"
|
||||||
|
locale=$(getLanguage "$lang" "code")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case "${version,,}" in
|
||||||
|
"win11${PLATFORM,,}" | "win11${PLATFORM,,}-enterprise" | "win11${PLATFORM,,}-enterprise-eval" )
|
||||||
|
url+="windows_arm_links"
|
||||||
|
pattern="11_business"
|
||||||
|
;;
|
||||||
|
"win11${PLATFORM,,}-ltsc" | "win11${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||||
|
url+="windows_arm_links"
|
||||||
|
pattern="11_iot_enterprise_ltsc"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}" | "win10${PLATFORM,,}-enterprise" | "win10${PLATFORM,,}-enterprise-eval" )
|
||||||
|
url+="windows_arm_links"
|
||||||
|
pattern="Pro_10"
|
||||||
|
locale="$language"
|
||||||
|
[[ "$locale" == "Chinese" ]] && locale="ChnSimp"
|
||||||
|
[[ "$locale" == "Chinese HK" ]] && locale="ChnTrad"
|
||||||
|
[[ "$locale" == "Chinese TW" ]] && locale="ChnTrad"
|
||||||
|
;;
|
||||||
|
"win10${PLATFORM,,}-ltsc" | "win10${PLATFORM,,}-enterprise-ltsc-eval" )
|
||||||
|
url+="windows_arm_links"
|
||||||
|
pattern="10_iot_enterprise_ltsc"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
local body=""
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing product page: ${url}"
|
||||||
|
body=$(curl --silent --max-time 30 --user-agent "$user_agent" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$url") || {
|
||||||
|
handle_curl_error "$?" "Massgrave"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
local list=""
|
||||||
|
list=$(echo "$body" | xmllint --html --nonet --xpath "//a[contains(text(), '.iso')]" - 2>/dev/null)
|
||||||
|
|
||||||
|
local result=""
|
||||||
|
result=$(echo "$list" | grep -i "${platform}" | grep "${pattern}" | grep -i -m 1 "${locale,,}_")
|
||||||
|
result=$(echo "$result" | sed -r 's/.*href="([^"]+).*/\1/g')
|
||||||
|
local page="$result"
|
||||||
|
|
||||||
|
if [ -z "$page" ]; then
|
||||||
|
if [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-"* ]]; then
|
||||||
|
error "No download in the $language language available for $desc!"
|
||||||
|
else
|
||||||
|
error "Failed to parse download link for $desc! Please report this at $SUPPORT/issues."
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "$DEBUG" == [Yy1]* ]] && echo "Parsing download page: ${page}"
|
||||||
|
result=$(curl --silent --max-time 30 --request GET --user-agent "$user_agent" --referer "$url" --head --proto =https --tlsv1.2 --http1.1 -- "$page") || {
|
||||||
|
handle_curl_error "$?" "Massgrave"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${result,,}" == *"content-type: text"* ]]; then
|
||||||
|
body=$(curl --silent --max-time 30 --user-agent "$user_agent" --referer "$url" --location --max-filesize 1M --fail --proto =https --tlsv1.2 --http1.1 -- "$page") || {
|
||||||
|
handle_curl_error "$?" "Massgrave"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
list=$(echo "$body" | xmllint --html --nonet --xpath "//a[contains(@href, '.iso')]" - 2>/dev/null)
|
||||||
|
list=$(echo "$list" | sed -r 's/.*href="([^"]+).*/\1/g')
|
||||||
|
page=$(echo "$list" | sed 's/&/\&/g;')
|
||||||
|
|
||||||
|
if [ -z "$page" ]; then
|
||||||
|
if [[ "${lang,,}" != "en" ]] && [[ "${lang,,}" != "en-"* ]]; then
|
||||||
|
error "No download in the $language language available for $desc!"
|
||||||
|
else
|
||||||
|
error "Failed to parse download link for $desc! Please report this at $SUPPORT/issues."
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
MG_URL="$page"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
getESD() {
|
getESD() {
|
||||||
|
|
||||||
local dir="$1"
|
local dir="$1"
|
||||||
@@ -457,7 +696,7 @@ getESD() {
|
|||||||
local eFile="esd_edition.xml"
|
local eFile="esd_edition.xml"
|
||||||
local fFile="products_filter.xml"
|
local fFile="products_filter.xml"
|
||||||
|
|
||||||
{ wget "$winCatalog" -O "$dir/$wFile" -q --timeout=30; rc=$?; } || :
|
{ wget "$winCatalog" -O "$dir/$wFile" -q --timeout=30 --no-http-keep-alive; rc=$?; } || :
|
||||||
|
|
||||||
msg="Failed to download $winCatalog"
|
msg="Failed to download $winCatalog"
|
||||||
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
|
(( rc == 3 )) && error "$msg , cannot write file (disk full?)" && return 1
|
||||||
@@ -583,7 +822,7 @@ downloadFile() {
|
|||||||
info "$msg..."
|
info "$msg..."
|
||||||
/run/progress.sh "$iso" "$size" "$msg ([P])..." &
|
/run/progress.sh "$iso" "$size" "$msg ([P])..." &
|
||||||
|
|
||||||
{ wget "$url" -O "$iso" -q --timeout=30 --show-progress "$progress"; rc=$?; } || :
|
{ wget "$url" -O "$iso" -q --timeout=30 --no-http-keep-alive --show-progress "$progress"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
|
||||||
@@ -610,13 +849,18 @@ downloadImage() {
|
|||||||
local iso="$1"
|
local iso="$1"
|
||||||
local version="$2"
|
local version="$2"
|
||||||
local lang="$3"
|
local lang="$3"
|
||||||
|
local delay=5
|
||||||
local tried="n"
|
local tried="n"
|
||||||
|
local success="n"
|
||||||
local url sum size base desc language
|
local url sum size base desc language
|
||||||
|
local msg="Will retry after $delay seconds..."
|
||||||
|
|
||||||
if [[ "${version,,}" == "http"* ]]; then
|
if [[ "${version,,}" == "http"* ]]; then
|
||||||
base=$(basename "$iso")
|
base=$(basename "$iso")
|
||||||
desc=$(fromFile "$base")
|
desc=$(fromFile "$base")
|
||||||
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
downloadFile "$iso" "$version" "" "" "" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -637,11 +881,23 @@ downloadImage() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if isMido "$version" "$lang"; then
|
if isMido "$version" "$lang"; then
|
||||||
|
|
||||||
tried="y"
|
tried="y"
|
||||||
|
success="n"
|
||||||
|
|
||||||
if getWindows "$version" "$lang" "$desc"; then
|
if getWindows "$version" "$lang" "$desc"; then
|
||||||
|
success="y"
|
||||||
|
else
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
getWindows "$version" "$lang" "$desc" && success="y"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$success" == "y" ]]; then
|
||||||
size=$(getMido "$version" "$lang" "size" )
|
size=$(getMido "$version" "$lang" "size" )
|
||||||
sum=$(getMido "$version" "$lang" "sum")
|
sum=$(getMido "$version" "$lang" "sum")
|
||||||
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
downloadFile "$iso" "$MIDO_URL" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -655,10 +911,20 @@ downloadImage() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
tried="y"
|
tried="y"
|
||||||
|
success="n"
|
||||||
|
|
||||||
if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
|
if getESD "$TMP/esd" "$version" "$lang" "$desc"; then
|
||||||
|
success="y"
|
||||||
|
else
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
getESD "$TMP/esd" "$version" "$lang" "$desc" && success="y"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$success" == "y" ]]; then
|
||||||
ISO="${ISO%.*}.esd"
|
ISO="${ISO%.*}.esd"
|
||||||
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
downloadFile "$ISO" "$ESD" "$ESD_SUM" "$ESD_SIZE" "$lang" "$desc" && return 0
|
||||||
rm -f "$ISO"
|
rm -f "$ISO"
|
||||||
ISO="$iso"
|
ISO="$iso"
|
||||||
fi
|
fi
|
||||||
@@ -677,11 +943,38 @@ downloadImage() {
|
|||||||
size=$(getSize "$i" "$version" "$lang")
|
size=$(getSize "$i" "$version" "$lang")
|
||||||
sum=$(getHash "$i" "$version" "$lang")
|
sum=$(getHash "$i" "$version" "$lang")
|
||||||
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
downloadFile "$iso" "$url" "$sum" "$size" "$lang" "$desc" && return 0
|
||||||
rm -f "$iso"
|
rm -f "$iso"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if isMG "$version" "$lang"; then
|
||||||
|
|
||||||
|
if [[ "$tried" != "n" ]]; then
|
||||||
|
info "Failed to download $desc, will try a diferent method now..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
tried="y"
|
||||||
|
success="n"
|
||||||
|
|
||||||
|
if getMG "$version" "$lang" "$desc"; then
|
||||||
|
success="y"
|
||||||
|
else
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
getMG "$version" "$lang" "$desc" && success="y"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$success" == "y" ]]; then
|
||||||
|
downloadFile "$iso" "$MG_URL" "" "" "$lang" "$desc" && return 0
|
||||||
|
info "$msg" && html "$msg" && sleep "$delay"
|
||||||
|
downloadFile "$iso" "$MG_URL" "" "" "$lang" "$desc" && return 0
|
||||||
|
rm -f "$iso"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
src/samba.sh
22
src/samba.sh
@@ -71,6 +71,9 @@ addShare() {
|
|||||||
echo " guest account = nobody"
|
echo " guest account = nobody"
|
||||||
echo " map to guest = Bad User"
|
echo " map to guest = Bad User"
|
||||||
echo " server min protocol = NT1"
|
echo " server min protocol = NT1"
|
||||||
|
echo " follow symlinks = yes"
|
||||||
|
echo " wide links = yes"
|
||||||
|
echo " unix extensions = no"
|
||||||
echo ""
|
echo ""
|
||||||
echo " # disable printing services"
|
echo " # disable printing services"
|
||||||
echo " load printers = no"
|
echo " load printers = no"
|
||||||
@@ -89,21 +92,20 @@ addShare "$share" "Data" "Shared" || error "Failed to create shared folder!"
|
|||||||
[ -d "/data2" ] && addShare "/data2" "Data2" "Shared"
|
[ -d "/data2" ] && addShare "/data2" "Data2" "Shared"
|
||||||
[ -d "/data3" ] && addShare "/data3" "Data3" "Shared"
|
[ -d "/data3" ] && addShare "/data3" "Data3" "Shared"
|
||||||
|
|
||||||
|
IFS=',' read -r -a dirs <<< "${SHARES:-}"
|
||||||
|
for dir in "${dirs[@]}"; do
|
||||||
|
[ ! -d "$dir" ] && continue
|
||||||
|
dir_name=$(basename "$dir")
|
||||||
|
addShare "$dir" "$dir_name" "Shared $dir_name" || error "Failed to create shared folder for $dir!"
|
||||||
|
done
|
||||||
|
|
||||||
if ! smbd; then
|
if ! smbd; then
|
||||||
error "Samba daemon failed to start!"
|
error "Samba daemon failed to start!"
|
||||||
smbd -i --debug-stdout || true
|
smbd -i --debug-stdout || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
legacy=""
|
if [[ "${BOOT_MODE:-}" == "windows_legacy" ]]; then
|
||||||
|
# Enable NetBIOS on Windows 7 and lower
|
||||||
if [ -f "$STORAGE/windows.old" ]; then
|
|
||||||
MT=$(<"$STORAGE/windows.old")
|
|
||||||
[[ "${MT,,}" == "pc-q35-2"* ]] && legacy="y"
|
|
||||||
[[ "${MT,,}" == "pc-i440fx-2"* ]] && legacy="y"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$legacy" ]; then
|
|
||||||
# Enable NetBIOS on Windows XP and lower
|
|
||||||
if ! nmbd; then
|
if ! nmbd; then
|
||||||
error "NetBIOS daemon failed to start!"
|
error "NetBIOS daemon failed to start!"
|
||||||
nmbd -i --debug-stdout || true
|
nmbd -i --debug-stdout || true
|
||||||
|
|||||||
Reference in New Issue
Block a user