mirror of
				https://github.com/dockur/windows.git
				synced 2025-11-04 06:15:27 +00:00 
			
		
		
		
	feat: Allow product key configuration (#1110)
This commit is contained in:
		
							parent
							
								
									b465f78646
								
							
						
					
					
						commit
						5ab42e9409
					
				
							
								
								
									
										14
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								readme.md
									
									
									
									
									
								
							@ -178,7 +178,7 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/mas
 | 
			
		||||
 | 
			
		||||
  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:
 | 
			
		||||
@ -201,13 +201,23 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/mas
 | 
			
		||||
 | 
			
		||||
### 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:
 | 
			
		||||
    REGION: "en-US"
 | 
			
		||||
    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:
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
set -Eeuo pipefail
 | 
			
		||||
 | 
			
		||||
: "${KEY:=""}"
 | 
			
		||||
: "${WIDTH:=""}"
 | 
			
		||||
: "${HEIGHT:=""}"
 | 
			
		||||
: "${VERIFY:=""}"
 | 
			
		||||
@ -1175,9 +1176,7 @@ prepareInstall() {
 | 
			
		||||
 | 
			
		||||
  local dir="$2"
 | 
			
		||||
  local desc="$3"
 | 
			
		||||
  local arch="$4"
 | 
			
		||||
  local key="$5"
 | 
			
		||||
  local driver="$6"
 | 
			
		||||
  local driver="$4"
 | 
			
		||||
  local drivers="/tmp/drivers"
 | 
			
		||||
 | 
			
		||||
  rm -rf "$drivers"
 | 
			
		||||
@ -1196,7 +1195,8 @@ prepareInstall() {
 | 
			
		||||
    error "Failed to extract drivers!" && return 1
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  local target
 | 
			
		||||
  local arch target
 | 
			
		||||
  [ -d "$dir/AMD64" ] && arch="amd64" || arch="x86"
 | 
			
		||||
  [[ "${arch,,}" == "x86" ]] && target="$dir/I386" || target="$dir/AMD64"
 | 
			
		||||
 | 
			
		||||
  if [ ! -f "$drivers/viostor/$driver/$arch/viostor.sys" ]; then
 | 
			
		||||
@ -1282,6 +1282,24 @@ prepareInstall() {
 | 
			
		||||
  [ -n "$PASSWORD" ] && password="$PASSWORD"
 | 
			
		||||
  [ -n "$USERNAME" ] && username=$(echo "$USERNAME" | sed 's/[^[:alnum:]@!._-]//g')
 | 
			
		||||
 | 
			
		||||
  if [[ "${driver,,}" == "xp" ]]; then
 | 
			
		||||
    if [[ "${arch,,}" == "x86" ]]; then
 | 
			
		||||
      # Windows XP Professional x86 generic key (no activation, trial-only)
 | 
			
		||||
      [ -z "$KEY" ] && KEY="DR8GV-C8V6J-BYXHG-7PYJR-DB66Y"
 | 
			
		||||
    else
 | 
			
		||||
      # Windows XP Professional x64 generic key (no activation, trial-only)
 | 
			
		||||
      [ -z "$KEY" ] && KEY="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G"
 | 
			
		||||
    fi
 | 
			
		||||
  else
 | 
			
		||||
    if [[ "${arch,,}" == "x86" ]]; then
 | 
			
		||||
      # Windows Server 2003 Standard x86 generic key (no activation, trial-only)
 | 
			
		||||
      [ -z "$KEY" ] && KEY="QKDCQ-TP2JM-G4MDG-VR6F2-P9C48"
 | 
			
		||||
    else
 | 
			
		||||
      # Windows Server 2003 Standard x64 generic key (no activation, trial-only)
 | 
			
		||||
      [ -z "$KEY" ] && KEY="P4WJG-WK3W7-3HM8W-RWHCK-8JTRY"
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  find "$target" -maxdepth 1 -type f -iname winnt.sif -exec rm {} \;
 | 
			
		||||
 | 
			
		||||
  {       echo "[Data]"
 | 
			
		||||
@ -1319,7 +1337,7 @@ prepareInstall() {
 | 
			
		||||
          echo "    FullName=\"$username\""
 | 
			
		||||
          echo "    ComputerName=\"*\""
 | 
			
		||||
          echo "    OrgName=\"Windows for Docker\""
 | 
			
		||||
          echo "    ProductKey=$key"
 | 
			
		||||
          echo "    ProductKey=$KEY"
 | 
			
		||||
          echo ""
 | 
			
		||||
          echo "[Identification]"
 | 
			
		||||
          echo "    JoinWorkgroup = WORKGROUP"
 | 
			
		||||
@ -1465,56 +1483,6 @@ prepareInstall() {
 | 
			
		||||
  return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prepare2k3() {
 | 
			
		||||
 | 
			
		||||
  local iso="$1"
 | 
			
		||||
  local dir="$2"
 | 
			
		||||
  local desc="$3"
 | 
			
		||||
  local driver="2k3"
 | 
			
		||||
  local arch key
 | 
			
		||||
 | 
			
		||||
  [ -d "$dir/AMD64" ] && arch="amd64" || arch="x86"
 | 
			
		||||
 | 
			
		||||
  if [[ "${arch,,}" == "x86" ]]; then
 | 
			
		||||
    # Windows Server 2003 Standard x86 generic key (no activation, trial-only)
 | 
			
		||||
    # This is not a pirated key, it comes from the official MS documentation.
 | 
			
		||||
    key="QKDCQ-TP2JM-G4MDG-VR6F2-P9C48"
 | 
			
		||||
  else
 | 
			
		||||
    # Windows Server 2003 Standard x64 generic key (no activation, trial-only)
 | 
			
		||||
    # This is not a pirated key, it comes from the official MS documentation.
 | 
			
		||||
    key="P4WJG-WK3W7-3HM8W-RWHCK-8JTRY"
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  prepareInstall "$iso" "$dir" "$desc" "$arch" "$key" "$driver" || return 1
 | 
			
		||||
 | 
			
		||||
  return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prepareXP() {
 | 
			
		||||
 | 
			
		||||
  local iso="$1"
 | 
			
		||||
  local dir="$2"
 | 
			
		||||
  local desc="$3"
 | 
			
		||||
  local driver="xp"
 | 
			
		||||
  local arch key
 | 
			
		||||
 | 
			
		||||
  [ -d "$dir/AMD64" ] && arch="amd64" || arch="x86"
 | 
			
		||||
 | 
			
		||||
  if [[ "${arch,,}" == "x86" ]]; then
 | 
			
		||||
    # Windows XP Professional x86 generic key (no activation, trial-only)
 | 
			
		||||
    # This is not a pirated key, it comes from the official MS documentation.
 | 
			
		||||
    key="DR8GV-C8V6J-BYXHG-7PYJR-DB66Y"
 | 
			
		||||
  else
 | 
			
		||||
    # Windows XP Professional x64 generic key (no activation, trial-only)
 | 
			
		||||
    # This is not a pirated key, it comes from the official MS documentation.
 | 
			
		||||
    key="B2RBK-7KPT9-4JP6X-QQFWM-PJD6G"
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  prepareInstall "$iso" "$dir" "$desc" "$arch" "$key" "$driver" || return 1
 | 
			
		||||
 | 
			
		||||
  return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
prepareLegacy() {
 | 
			
		||||
 | 
			
		||||
  local iso="$1"
 | 
			
		||||
@ -1601,11 +1569,11 @@ setMachine() {
 | 
			
		||||
    "win2k"* )
 | 
			
		||||
      ETFS="[BOOT]/Boot-NoEmul.img" ;;
 | 
			
		||||
    "winxp"* )
 | 
			
		||||
      if ! prepareXP "$iso" "$dir" "$desc"; then
 | 
			
		||||
      if ! prepareInstall "$iso" "$dir" "$desc" "xp"; then
 | 
			
		||||
        error "Failed to prepare $desc ISO!" && return 1
 | 
			
		||||
      fi ;;
 | 
			
		||||
    "win2003"* )
 | 
			
		||||
      if ! prepare2k3 "$iso" "$dir" "$desc"; then
 | 
			
		||||
      if ! prepareInstall "$iso" "$dir" "$desc" "2k3"; then
 | 
			
		||||
        error "Failed to prepare $desc ISO!" && return 1
 | 
			
		||||
      fi ;;
 | 
			
		||||
  esac
 | 
			
		||||
 | 
			
		||||
@ -681,6 +681,11 @@ updateXML() {
 | 
			
		||||
    sed -i "s/SERVERSTANDARD<\/Value>/SERVER${EDITION^^}<\/Value>/g" "$asset"
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  if [ -n "$KEY" ]; then
 | 
			
		||||
    sed -i '/<ProductKey>/,/<\/ProductKey>/d' "$asset"
 | 
			
		||||
    sed -i "s/<\/UserData>/  <ProductKey>\n          <Key>${KEY}<\/Key>\n          <WillShowUI>OnError<\/WillShowUI>\n        <\/ProductKey>\n      <\/UserData>/g" "$asset"
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user