Commit 8f826b34 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add support for 32bit versions of Windows

* Add processorArchitecture="x86" entries in the default Unattend.xml
* Detect the image's architecture and apply the unattend.xml changes to
  the suitable components
parent 85ea3ed5
......@@ -720,6 +720,27 @@ get_ufstype() {
esac
}
get_windows_architecture() {
local target hive current
target="$1"
hive="$target/windows/system32/config/system"
current=$($HIVEXGET "$hive" Select Current)
if [ "$current" = "" ]; then
log_error "Unable to find CurrentControlSet in the registry"
fi
# Pad the value with zeros
current=$(printf "%03d" "$current")
$HIVEXGET "$hive" 'ControlSet'${current}'\Control\Session Manager\Environment' \
| grep PROCESSOR_ARCHITECTURE \
| cut -d= -f2 \
| sed 's/"//g' \
| tr [A-Z] [a-z]
}
check_if_root() {
local os fd device is_root args windows_fs linux_fs freebsd_fs netbsd_fs \
openbsd_fs supported_fs current_version hive major minor
......
......@@ -61,7 +61,7 @@ windows-legacy_hostname() {
}
windows_hostname() {
local target hostname unattend xpath
local target hostname unattend arch xpath
target="$1"
hostname="$2"
......@@ -76,8 +76,13 @@ windows_hostname() {
if [ -z "$unattend" ]; then
log_error "No Unattend.xml found in the instance."
fi
arch=$(get_windows_architecture "$target")
if [ -z "$arch" ]; then
log_error "Unable to determine windows architecture"
fi
xpath='/_:unattend/_:settings[@pass="specialize"]/_:component[@name="Microsoft-Windows-Shell-Setup"]'
xpath='/_:unattend/_:settings[@pass="specialize"]/'
xpath+='_:component[@name="Microsoft-Windows-Shell-Setup" and @processorArchitecture="'${arch}'"]'
if ! $XMLSTARLET sel -t -v "$xpath" "$unattend" &> /dev/null; then
log_error 'Error in unattend.xml: Component "Microsoft-Windows-Shell-Setup" '\
'is needed but missing from "specialize" pass.'
......
......@@ -75,7 +75,7 @@ netbsd_change_shadow_entry() {
}
windows_password() {
local target password sam names wcm xpath unattend
local target password sam names wcm xpath unattend arch
target="$1"
password="$2"
sam="$target/windows/system32/config/sam"
......@@ -95,7 +95,7 @@ windows_password() {
fi
names="$($HIVEXREGEDIT --export "$sam" '\SAM\Domains\Account\Users\Names' \
| gawk 'match($0, /Names\\([^\\]+)\]/, n) { print n[1]; }' )"
| gawk 'match($0, /Names\\([^\\]+)\]/, n) { print n[1]; }')"
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = 'windows' ]; then
# Add the users that get created by the unattend.xml file
......@@ -104,11 +104,15 @@ windows_password() {
if [ -z "$unattend" ]; then
log_error "No unattend.xml file found in the image."
fi
arch="$(get_windows_architecture "$target")"
if [ -z "$arch" ]; then
log_error "Unable to determine Windows architecture"
fi
# Find the wcm namespace value
wcm=$($XMLSTARLET sel -t -v '(//namespace::*[name()="wcm"])[1]' "$unattend")
xpath='/_:unattend/_:settings/_:component/_:UserAccounts/'
xpath='/_:unattend/_:settings/_:component[@processorArchitecture="'$arch'"]/_:UserAccounts/'
xpath+='_:LocalAccounts/_:LocalAccount[@wcm:action="add"]/_:Name'
names+=$($XMLSTARLET sel -N wcm="$wcm" -t -v "$xpath" "$unattend") || true
......
......@@ -8,6 +8,13 @@
<RegisteredOrganization>Microsoft</RegisteredOrganization>
<RegisteredOwner>AutoBVT</RegisteredOwner>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<TimeZone>GTB Standard Time</TimeZone>
<ComputerName>*</ComputerName>
<RegisteredOrganization>Microsoft</RegisteredOrganization>
<RegisteredOwner>AutoBVT</RegisteredOwner>
</component>
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
......@@ -37,6 +44,35 @@
</RunSynchronousCommand>
</RunSynchronous>
</component>
<component name="Microsoft-Windows-Deployment" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Description>Change User Passwords</Description>
<Order>1</Order>
<Path>C:\Windows\SnfScripts\ChangeAdminPassword.cmd</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Description>Extend the filesystem</Description>
<Order>2</Order>
<Path>diskpart.exe /s C:\Windows\SnfScripts\ExtendFilesystem</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Description>Enable RDP</Description>
<Order>3</Order>
<Path>cmd /C reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Description>Enable Automatic Updates</Description>
<Order>4</Order>
<Path>cmd /C reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 4 /f</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Description>Supress local user account setup</Description>
<Order>5</Order>
<Path>cmd /C reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\OOBE /v UnattendCreatedUser /t REG_DWORD /d 1 /f</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
......@@ -46,6 +82,13 @@
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>el-GR</UserLocale>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>el-GR</UserLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Display>
<ColorDepth>24</ColorDepth>
......@@ -58,6 +101,18 @@
<NetworkLocation>Other</NetworkLocation>
</OOBE>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Display>
<ColorDepth>24</ColorDepth>
<HorizontalResolution>1024</HorizontalResolution>
<VerticalResolution>768</VerticalResolution>
</Display>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<ProtectYourPC>1</ProtectYourPC>
<NetworkLocation>Other</NetworkLocation>
</OOBE>
</component>
</settings>
<cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverstandard.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment