mirror of
https://github.com/dockur/windows.git
synced 2026-07-27 21:42:36 +07:00
feat: Assign HOST as the Windows computer name (#1897)
This commit is contained in:
+1
-1
@@ -53,7 +53,7 @@ An empty default means the variable is unset and its value is determined automat
|
||||
|---|---|---|
|
||||
| `NETWORK` | | Network mode, such as `nat`, `user`, or `N` to disable networking. |
|
||||
| `DHCP` | `N` | Enables macvtap networking so Windows receives an address from the external LAN through DHCP. |
|
||||
| `HOST` | `Windows` | Hostname assigned to Windows. |
|
||||
| `HOST` | `Windows` | Computer name assigned to Windows and advertised on the network. |
|
||||
| `IP` | | Overrides the automatically selected guest IPv4 address. |
|
||||
| `MAC` | | Guest network adapter MAC address. |
|
||||
| `ADAPTER` | `virtio-net-pci` | QEMU network adapter model. |
|
||||
|
||||
+33
-2
@@ -2,6 +2,7 @@
|
||||
set -Eeuo pipefail
|
||||
|
||||
: "${KEY:=""}"
|
||||
: "${HOST:=""}"
|
||||
: "${WIDTH:=""}"
|
||||
: "${HEIGHT:=""}"
|
||||
: "${VERIFY:=""}"
|
||||
@@ -20,6 +21,7 @@ set -Eeuo pipefail
|
||||
|
||||
# Sanitize variables
|
||||
KEY=$(strip "$KEY")
|
||||
HOST=$(strip "$HOST")
|
||||
WIDTH=$(strip "$WIDTH")
|
||||
HEIGHT=$(strip "$HEIGHT")
|
||||
DOMAIN=$(strip "$DOMAIN")
|
||||
@@ -1380,6 +1382,33 @@ validateProductKey() {
|
||||
return 0
|
||||
}
|
||||
|
||||
validateComputerName() {
|
||||
|
||||
local value="$1"
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
value="$APP"
|
||||
HOST="$value"
|
||||
fi
|
||||
|
||||
if [ "${#value}" -gt 15 ]; then
|
||||
error "The HOST variable cannot contain more than 15 characters!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! "$value" =~ ^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$ ]]; then
|
||||
error "The HOST variable may only contain letters, digits, and hyphens, and cannot start or end with a hyphen!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$value" =~ ^[0-9]+$ ]]; then
|
||||
error "The HOST variable cannot contain only digits!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
validateLegacyText() {
|
||||
|
||||
local name="$1"
|
||||
@@ -1719,6 +1748,7 @@ prepareInstall() {
|
||||
|
||||
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
||||
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
||||
validateComputerName "$HOST" || return 1
|
||||
validateLegacyText "APP" "$APP" "$desc" || return 1
|
||||
validateLegacyText "ENGINE" "$ENGINE" "$desc" || return 1
|
||||
|
||||
@@ -1727,12 +1757,13 @@ prepareInstall() {
|
||||
|
||||
local username="${USERNAME:-Docker}"
|
||||
local password="${PASSWORD:-admin}"
|
||||
local sifUsername sifPassword sifOrganization
|
||||
local sifHost sifUsername sifPassword sifOrganization
|
||||
local regUsername regPassword
|
||||
|
||||
validateLegacyUsername "$username" "$desc" || return 1
|
||||
validateLegacyPassword "$password" "$desc" || return 1
|
||||
|
||||
sifHost=$(escapeSIFValue "$HOST") || return 1
|
||||
sifUsername=$(escapeSIFValue "$username") || return 1
|
||||
sifPassword=$(escapeSIFValue "$password") || return 1
|
||||
sifOrganization=$(escapeSIFValue "$APP for $ENGINE") || return 1
|
||||
@@ -1774,7 +1805,7 @@ prepareInstall() {
|
||||
echo ""
|
||||
echo "[UserData]"
|
||||
echo " FullName=\"$sifUsername\""
|
||||
echo " ComputerName=\"*\""
|
||||
echo " ComputerName=\"$sifHost\""
|
||||
echo " OrgName=\"$sifOrganization\""
|
||||
echo " $product"
|
||||
echo ""
|
||||
|
||||
+4
-1
@@ -1027,19 +1027,22 @@ updateXML() {
|
||||
local language="$2"
|
||||
local app value culture region keyboard edition key
|
||||
local user raw_user user_xml auth_user safe_user
|
||||
local admin pass pw domain qualifier
|
||||
local admin pass pw domain qualifier host
|
||||
|
||||
[ -z "$WIDTH" ] && WIDTH="1280"
|
||||
[ -z "$HEIGHT" ] && HEIGHT="720"
|
||||
|
||||
validateResolution "WIDTH" "$WIDTH" 320 || return 1
|
||||
validateResolution "HEIGHT" "$HEIGHT" 200 || return 1
|
||||
validateComputerName "$HOST" || return 1
|
||||
validateProductKey "$KEY" || return 1
|
||||
validatePassword "$PASSWORD" || return 1
|
||||
|
||||
app=$(escapeXMLSed "$APP for $ENGINE") || return 1
|
||||
host=$(escapeXMLSed "$HOST") || return 1
|
||||
|
||||
sed -i "s|>Windows for Docker<|>$app<|g" "$asset" || return 1
|
||||
sed -i -E "s|<ComputerName>[^<]*</ComputerName>|<ComputerName>$host</ComputerName>|g" "$asset" || return 1
|
||||
sed -i "s|<VerticalResolution>1080</VerticalResolution>|<VerticalResolution>$HEIGHT</VerticalResolution>|g" "$asset" || return 1
|
||||
sed -i "s|<HorizontalResolution>1920</HorizontalResolution>|<HorizontalResolution>$WIDTH</HorizontalResolution>|g" "$asset" || return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user