From 2dbed4ead7e18dc94332b3aa0481d456ae70488a Mon Sep 17 00:00:00 2001 From: Kroese Date: Thu, 13 Mar 2025 12:45:24 +0100 Subject: [PATCH] feat: Allow product key configuration (#275) --- readme.md | 13 +++++++++++-- src/define.sh | 1 + src/install.sh | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index d6a24ef..63b9c16 100644 --- a/readme.md +++ b/readme.md @@ -174,7 +174,7 @@ The example folder `./example` will be available as ` \\host.lan\Data`. By default, a user called `Docker` (with an empty password) is created during installation. - If you want to use different credentials, you can configure them (only BEFORE installation) in your compose file: + If you want to use different credentials, you can configure them in your compose file (only before installation): ```yaml environment: @@ -197,7 +197,7 @@ The example folder `./example` will be available as ` \\host.lan\Data`. ### How do I select the keyboard layout? - If you want to use a keyboard layout or locale that is not the default for your selected language, before installation you can add `KEYBOARD` and `REGION` variables like this: + If you want to use a keyboard layout or locale that is not the default for your selected language, you can add `KEYBOARD` and `REGION` variables like this (before installation): ```yaml environment: @@ -205,6 +205,15 @@ The example folder `./example` will be available as ` \\host.lan\Data`. KEYBOARD: "en-US" ``` +### How do I set the product key? + + By default, an evaluation version of Windows will be installed, but if you have product key you can add a `KEY` variable like this (before installation): + + ```yaml + environment: + KEY: "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" + ``` + ### How do I install a custom image? In order to download an unsupported ISO image, specify its URL in the `VERSION` environment variable: diff --git a/src/define.sh b/src/define.sh index 9b93ac2..8bcb7f6 100644 --- a/src/define.sh +++ b/src/define.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -Eeuo pipefail +: "${KEY:=""}" : "${WIDTH:=""}" : "${HEIGHT:=""}" : "${VERIFY:=""}" diff --git a/src/install.sh b/src/install.sh index 0916f69..e184b5e 100644 --- a/src/install.sh +++ b/src/install.sh @@ -681,6 +681,11 @@ updateXML() { sed -i "s/SERVERSTANDARD<\/Value>/SERVER${EDITION^^}<\/Value>/g" "$asset" fi + if [ -n "$KEY" ]; then + sed -i '//,/<\/ProductKey>/d' "$asset" + sed -i "s/<\/UserData>/ \n ${KEY}<\/Key>\n OnError<\/WillShowUI>\n <\/ProductKey>\n <\/UserData>/g" "$asset" + fi + return 0 }