Revision 6196f457
/dev/null | ||
---|---|---|
1 |
#! /bin/bash |
|
2 |
|
|
3 |
### BEGIN TASK INFO |
|
4 |
# Provides: AddDeleteUnattendScript |
|
5 |
# RunBefore: UmountImage |
|
6 |
# RunAfter: MountImage |
|
7 |
# Short-Description: Script that removes Unattend.xml after setup has finished |
|
8 |
### END TASK INFO |
|
9 |
|
|
10 |
set -e |
|
11 |
. "@commondir@/common.sh" |
|
12 |
|
|
13 |
if [ ! -d "$SNF_IMAGE_TARGET" ]; then |
|
14 |
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing" |
|
15 |
fi |
|
16 |
|
|
17 |
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then |
|
18 |
# Make sure Unattend.xml is removed after setup has finished |
|
19 |
mkdir -p "$SNF_IMAGE_TARGET/Windows/Setup/Scripts" |
|
20 |
echo "del /Q /F C:\Unattend.xml" > "$SNF_IMAGE_TARGET/Windows/Setup/Scripts/SetupComplete.cmd" |
|
21 |
fi |
|
22 |
|
|
23 |
exit 0 |
|
24 |
|
|
25 |
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai : |
b/snf-image-helper/tasks/40FilesystemResizeMounted.in | ||
---|---|---|
25 | 25 |
if [ "$ptype" = "ntfs" ]; then |
26 | 26 |
# Write a diskpart script to %SystemDrive%\Windows\SnfScripts. Sysprep will |
27 | 27 |
# try to execute this script during the specialize pass. |
28 |
mkdir -p "$SNF_IMAGE_TARGET/Windows/SnfScripts" |
|
29 | 28 |
cat > "$SNF_IMAGE_TARGET/Windows/SnfScripts/ExtendFilesystem" <<EOF |
30 | 29 |
select disk 0 |
31 | 30 |
select volume $id |
b/snf-image-helper/tasks/40InstallUnattend.in | ||
---|---|---|
18 | 18 |
exit 0 |
19 | 19 |
fi |
20 | 20 |
|
21 |
if [ -f "@commondir@/unattend.xml" ]; then |
|
22 |
cat "@commondir@/unattend.xml" > "$SNF_IMAGE_TARGET/Unattend.xml" |
|
23 |
else |
|
21 |
if [ ! -f "@commondir@/unattend.xml" ]; then |
|
24 | 22 |
log_error "File \`@commondir@/unattend.xml' is missing." |
25 | 23 |
fi |
26 | 24 |
|
25 |
target=$SNF_IMAGE_TARGET |
|
26 |
mkdir -p "$target/Windows/Setup/Scripts" |
|
27 |
|
|
28 |
cat "@commondir@/unattend.xml" > "$target/Unattend.xml" |
|
29 |
echo "del /Q /F C:\Unattend.xml" > \ |
|
30 |
"$target/Windows/Setup/Scripts/SetupComplete.cmd" |
|
31 |
|
|
32 |
mkdir -p "$target/Windows/SnfScripts" |
|
33 |
|
|
34 |
echo "exit" > "$target/Windows/SnfScripts/ExtendFilesystem" |
|
35 |
echo "del /Q /F C:\Windows\SnfScripts\ExtendFilesystem" >> \ |
|
36 |
"$target/Windows/Setup/Scripts/SetupComplete.cmd" |
|
37 |
|
|
38 |
echo "@echo off" > "$target/Windows/SnfScripts/ChangeAdminPassword.cmd" |
|
39 |
# For security reasons, overwrite the file before deleting... |
|
40 |
spaces=$(printf "%200s"); |
|
41 |
echo "echo ${spaces// /X} > C:\Windows\SnfScripts\ChangeAdminPassword.cmd" >> \ |
|
42 |
"$target/Windows/Setup/Scripts/SetupComplete.cmd" |
|
43 |
echo "del /Q /F C:\Windows\SnfScripts\ChangeAdminPassword.cmd" >> \ |
|
44 |
"$target/Windows/Setup/Scripts/SetupComplete.cmd" |
|
45 |
|
|
46 |
echo "rmdir C:\Windows\SnfScripts" >> \ |
|
47 |
"$target/Windows/Setup/Scripts/SetupComplete.cmd" |
|
48 |
|
|
27 | 49 |
exit 0 |
28 | 50 |
|
29 | 51 |
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai : |
b/snf-image-helper/tasks/50ChangePassword.in | ||
---|---|---|
14 | 14 |
local target="$1" |
15 | 15 |
local password="$2" |
16 | 16 |
|
17 |
local tmp_unattend="$(mktemp)" |
|
18 |
add_cleanup rm "$tmp_unattend" |
|
19 |
|
|
20 | 17 |
echo -n "Installing new admin password..." |
21 | 18 |
|
22 |
local namespace="urn:schemas-microsoft-com:unattend" |
|
23 |
|
|
24 |
"$XMLSTARLET" ed -N x=$namespace -u "/x:unattend/x:settings/x:component/x:UserAccounts/x:AdministratorPassword/x:Value" -v "$password" "$target/Unattend.xml" > "$tmp_unattend" |
|
25 |
|
|
26 |
cat "$tmp_unattend" > "$target/Unattend.xml" |
|
19 |
echo "@echo off" > "$target/Windows/SnfScripts/ChangeAdminPassword.cmd" |
|
20 |
echo "net user Administrator $password" >> \ |
|
21 |
"$target/Windows/SnfScripts/ChangeAdminPassword.cmd" |
|
27 | 22 |
echo done |
28 | 23 |
} |
29 | 24 |
|
b/snf-image-helper/unattend.xml | ||
---|---|---|
17 | 17 |
<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"> |
18 | 18 |
<RunSynchronous> |
19 | 19 |
<RunSynchronousCommand wcm:action="add"> |
20 |
<Description>Extend the filesystem</Description>
|
|
20 |
<Description>Enable Build-in Account</Description>
|
|
21 | 21 |
<Order>1</Order> |
22 |
<Path>net user administrator /ACTIVE:YES /LOGONPASSWORDCHG:NO /EXPIRES:NEVER /PASSWORDREQ:YES</Path> |
|
23 |
</RunSynchronousCommand> |
|
24 |
<RunSynchronousCommand wcm:action="add"> |
|
25 |
<Description>Change Administrator Password</Description> |
|
26 |
<Order>2</Order> |
|
27 |
<Path>C:\Windows\SnfScripts\ChangeAdminPassword.cmd</Path> |
|
28 |
</RunSynchronousCommand> |
|
29 |
<RunSynchronousCommand wcm:action="add"> |
|
30 |
<Description>Extend the filesystem</Description> |
|
31 |
<Order>3</Order> |
|
22 | 32 |
<Path>diskpart.exe /s C:\Windows\SnfScripts\ExtendFilesystem</Path> |
23 | 33 |
</RunSynchronousCommand> |
24 | 34 |
<RunSynchronousCommand wcm:action="add"> |
25 | 35 |
<Description>Enable RDP</Description> |
26 |
<Order>2</Order>
|
|
36 |
<Order>4</Order>
|
|
27 | 37 |
<Path>cmd /C reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f</Path> |
28 | 38 |
</RunSynchronousCommand> |
29 | 39 |
</RunSynchronous> |
... | ... | |
46 | 56 |
<OOBE> |
47 | 57 |
<HideEULAPage>true</HideEULAPage> |
48 | 58 |
</OOBE> |
49 |
<UserAccounts> |
|
50 |
<AdministratorPassword> |
|
51 |
<Value>Admin1</Value> |
|
52 |
<PlainText>true</PlainText> |
|
53 |
</AdministratorPassword> |
|
54 |
</UserAccounts> |
|
55 | 59 |
</component> |
56 | 60 |
</settings> |
57 | 61 |
<cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverstandard.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> |
Also available in: Unified diff