Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Bob Tanner
packer-windows
Commits
5f29bbec
Commit
5f29bbec
authored
Oct 07, 2013
by
dylanmei
Browse files
Rollup vm guest tools into one script wip
parent
a09d7a64
Changes
9
Hide whitespace changes
Inline
Side-by-side
scripts/chocolatey.bat
View file @
5f29bbec
set
TEMP
=
C
:\Windows\Temp
powershell
-NoProfile -ExecutionPolicy
unrestricted
-Command
"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
cmd
/c
setx
/m
PATH
"
%path%
;C:\\Chocolatey\bin"
scripts/hotfix-KB2842230.bat
0 → 100644
View file @
5f29bbec
:: Windows 8 / Windows 2012 require KB2842230 hotfix
:: The Windows Remote Management (WinRM) service does not use the customized value of the MaxMemoryPerShellMB quota.
:: Instead, the WinRM service uses the default value, which is 150 MB.
:: http://hotfixv4.microsoft.com/Windows%208%20RTM/nosp/Fix452763/9200/free/463941_intl_x64_zip.exe
@echo
off
set
hotfix
=
"C:\Windows\Temp\Windows8-RT-KB2842230-x64.msu"
if
not
exist
%hotfix%
goto
:eof
:: get windows version
for
/f
"tokens=2 delims=[]"
%%G
in
(
'ver'
)
do
(
set
_version
=
%%G
)
for
/f
"tokens=2,3,4 delims=. "
%%G
in
(
'echo
%_version%
'
)
do
(
set
_major
=
%%G
&
set
_minor
=
%%H
&
set
_build
=
%%I
)
:: 6.2 or 6.3
if
%_major%
neq
6
goto
:eof
if
%_minor%
lss
2
goto
:eof
if
%_minor%
gtr
3
goto
:eof
@echo
on
start
/wait
wusa
"
%hotfix%
"
/quiet /norestart
scripts/hotfix-KB2842230.ps1
deleted
100644 → 0
View file @
a09d7a64
$winver
=
[
System.Environment
]::
OSVersion.Version
# Windows 8 / Windows 2012 require KB2842230 hotfix
# The Windows Remote Management (WinRM) service does not use the customized value of the MaxMemoryPerShellMB quota.
# Instead, the WinRM service uses the default value, which is 150 MB.
if
(
$winver
.
Major
-eq
6
-and
(
$winver
.
Minor
-eq
2
-or
$winver
.
Minor
-eq
3
))
{
#$HotfixUrl = "http://hotfixv4.microsoft.com/Windows%208%20RTM/nosp/Fix452763/9200/free/463941_intl_x64_zip.exe"
$HotfixMsu
=
"A:\Windows8-RT-KB2842230-x64.msu"
if
(
Test-Path
$HotfixMsu
)
{
Write-Host
"Executing KB2842230 hotfix"
start-process
-NoNewWindow
-FilePath
"wusa.exe"
-ArgumentList
"
$HotfixMsu
/quiet /norestart"
# Damn thing exists immediately.
Start-Sleep
-s
60
Write-Host
"A reboot will be required before Chocolatey can be used via Puppet"
}
}
scripts/openssh-6.2.bat
View file @
5f29bbec
@rem setup openssh
if
exist
a
:\openssh
-
6
.2.exe
(
copy
a
:\openssh
-
6
.2.exe
C
:\windows\Temp
)
else
(
powershell
-Command
"(New-Object System.Net.WebClient).DownloadFile('http://www.mls-software.com/files/setupssh-6.2p2-1-v1(x64).exe', 'C:\Windows\Temp\openssh-6.2.exe')"
)
:: setup openssh
powershell
-Command
"(New-Object System.Net.WebClient).DownloadFile('http://www.mls-software.com/files/setupssh-6.2p2-1-v1(x64).exe', 'C:\Windows\Temp\openssh-6.2.exe')"
cmd
/c
C
:\Windows\temp\openssh
-
6
.2.exe
/S /port
=
22
/privsep
=
1
/password
=
D
@rj33l1ng
cmd
/c
echo
PermitUserEnvironment
yes
>>
"C:\Program Files\OpenSSH\etc\sshd_config"
powershell
-Command
"Start-Sleep -s 10"
net
stop
opensshd
@rem
ensure vagrant can log in
::
ensure vagrant can log in
mkdir
"C:\Users\vagrant\.ssh"
cmd
/c
C
:\Windows\System32\icacls.exe
"C:\Users\vagrant"
/grant
vagrant
:
(
OI
)(
CI
)
F
cmd
/c
C
:\Windows\System32\icacls.exe
"C:\Program Files\OpenSSH\bin"
/grant
vagrant
:
(
OI
)
RX
cmd
/c
C
:\Windows\System32\icacls.exe
"C:\Program Files\OpenSSH\usr\sbin"
/grant
vagrant
:
(
OI
)
RX
powershell
-Command
"(Get-Content 'C:\Program Files\OpenSSH\etc\passwd') | Foreach-Object { $_ -replace '/home/(\w+)', '/cygdrive/c/Users/$1' } | Set-Content 'C:\Program Files\OpenSSH\etc\passwd'"
@rem
use Windows\Temp as /tmp location
::
use Windows\Temp as /tmp location
rd
/S /Q
"C:\Program Files\OpenSSH\tmp"
cmd
/c
""
C
:\Program
Files
\OpenSSH\bin\junction.exe
" /accepteula "
C
:\Program
Files
\OpenSSH\tmp
" C:\Windows\Temp"
cmd
/c
C
:\Windows\System32\icacls.exe
"C:\Windows\Temp"
/grant
vagrant
:
(
OI
)(
CI
)
F
echo
TEMP
=
C
:\\Windows\\Temp
>
C
:\Users\vagrant\.ssh\environment
@rem
configure firewall
::
configure firewall
netsh
advfirewall
firewall
add
rule
name
=
"SSHD"
dir
=
in
action
=
allow
service
=
OpenSSHd
enable
=
yes
netsh
advfirewall
firewall
add
rule
name
=
"SSHD"
dir
=
in
action
=
allow
program
=
"C:\Program Files\OpenSSH\usr\sbin\sshd.exe"
enable
=
yes
netsh
advfirewall
firewall
add
rule
name
=
"ssh"
dir
=
in
action
=
allow
protocol
=
TCP
localport
=
22
net
start
opensshd
scripts/vagrant-ssh.bat
View file @
5f29bbec
@rem
vagrant public key
::
vagrant public key
mkdir
"C:\Users\vagrant\.ssh"
if
exist
a
:\vagrant.pub
(
copy
a
:\vagrant.pub
C
:\Users\vagrant\.ssh\authorized_keys
...
...
scripts/virtualbox-tools.bat
deleted
100644 → 0
View file @
a09d7a64
@rem There needs to be Oracle CA (Certificate Authority) certificates installed in order
@rem to prevent user intervention popups which will undermine a silent installation.
cmd
/c
certutil
-addstore -f
"TrustedPublisher"
A
:\oracle
-cert
.cer
cmd
/c
E
:\VBoxWindowsAdditions.exe
/S
scripts/vm-guest-tools.bat
0 → 100644
View file @
5f29bbec
if
"
%PACKER_BUILDER_TYPE%
"
eq
"vmware"
goto
:vmware
if
"
%PACKER_BUILDER_TYPE%
"
eq
"virtualbox"
goto
:virtualbox
goto
:eof
:vmware
if
not
exist
"C:\Windows\Temp\7z920-x64.msi"
(
powershell
-Command
"(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')"
)
cmd
/c
msiexec
/qb /i
C
:\Windows\Temp\7z920
-x
64
.msi
if
not
exist
"C:\Windows\Temp\VMWare\setup.exe"
(
powershell
-Command
"(New-Object System.Net.WebClient).DownloadFile('http://softwareupdate.vmware.com/cds/vmw-desktop/ws/10.0.0/1295980/windows/packages/tools-windows-9.6.0.exe.tar', 'C:\Windows\Temp\vmware-tools.exe.tar')"
cmd
/c
"C:\Program Files\7-Zip\7z.exe"
x
C
:\Windows\Temp\vmware
-tools
.exe.tar
-oC
:\Windows\Temp
cmd
/c
C
:\Windows\Temp\tools
-windows
-
9
.6.0
cmd
/c
""
C
:\Program
Files
\7
-Zip
\7z.exe
" x "
C
:\Program
Files
(
x86
)
\VMWare\tools
-windows
\windows.iso
" -oC:\Windows\Temp\VMWare"
del
/F /S /Q
"C:\Program Files (x86)\VMWare"
)
cmd
/c
C
:\Windows\Temp\VMWare\setup.exe
/S /v
"/qn REBOOT=R\"
cmd
/c
msiexec
/qb /x
C
:\Windows\Temp\7z920
-x
64
.msi
goto
:eof
:virtualbox
:: There needs to be Oracle CA (Certificate Authority) certificates installed in order
:: to prevent user intervention popups which will undermine a silent installation.
cmd
/c
certutil
-addstore -f
"TrustedPublisher"
A
:\oracle
-cert
.cer
cmd
/c
E
:\VBoxWindowsAdditions.exe
/S
goto
:eof
scripts/vmware-tools.sh
deleted
100644 → 0
View file @
a09d7a64
#!/bin/sh
set
-x
if
[
"
$PACKER_BUILDER_TYPE
"
!=
"vmware"
]
;
then
echo
"not building vmware, skipping"
exit
fi
# 7zip will allow us to extract a file from an ISO
wget http://downloads.sourceforge.net/sevenzip/7z920-x64.msi
msiexec /qb /i 7z920-x64.msi
# Download VMware Tools For Windows
mkdir
/home/vagrant/vmware
chown
-R
vagrant /home/vagrant/vmware
cd
/home/vagrant/vmware
wget http://softwareupdate.vmware.com/cds/vmw-desktop/ws/10.0.0/1295980/windows/packages/tools-windows-9.6.0.exe.tar
tar
-xvf
/home/vagrant/vmware/tools-windows-9.6.0.exe.tar
rm
-rf
/home/vagrant/vmware/tools-windows-9.6.0.exe.tar
chown
-R
vagrant /home/vagrant/vmware
# Install the VMware Tools
/home/vagrant/vmware/tools-windows-9.6.0.exe
rm
-rf
/home/vagrant/vmware/tools-windows-9.6.0.exe
/cygdrive/c/Program
\
Files/7-Zip/7z.exe x C:
\\
Program
\
Files
\ \(
x86
\)\\
VMware
\\
tools-windows
\\
windows.iso
rm
-rf
C:
\\
Program
\
Files
\ \(
x86
\)\\
VMware
\\
tools-windows
\\
windows.iso
chown
-R
vagrant /home/vagrant/vmware
cmd.exe /c
"C:
\\
cygwin
\\
home
\\
vagrant
\\
vmware
\\
setup.exe /S /v
\"
/qn REBOOT=R
\"
"
rm
-rf
/home/vagrant/vmware
cd
/home/vagrant
msiexec /qb /x 7z920-x64.msi
rm
-rf
7z920-x64.msi
sleep
1
windows_2012.json
View file @
5f29bbec
...
...
@@ -4,12 +4,12 @@
"iso_url"
:
"./iso/en_windows_server_2012_x64_dvd_915478.iso"
,
"iso_checksum_type"
:
"md5"
,
"iso_checksum"
:
"da91135483e24689bfdaf05d40301506"
,
"headless"
:
tru
e
,
"headless"
:
fals
e
,
"boot_wait"
:
"5m"
,
"ssh_username"
:
"vagrant"
,
"ssh_password"
:
"vagrant"
,
"ssh_wait_timeout"
:
"2h"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Vagrant
Shutdown
\"
"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Packer
Shutdown
\"
"
,
"guest_os_type"
:
"windows8srv-64"
,
"disk_size"
:
61440
,
"vnc_port_min"
:
5900
,
...
...
@@ -34,9 +34,8 @@
"boot_wait"
:
"5m"
,
"ssh_username"
:
"vagrant"
,
"ssh_password"
:
"vagrant"
,
"ssh_wait_timeout"
:
"8h"
,
"shutdown_command"
:
"shutdown /s /t 4800 /f /d p:4:1 /c
\"
Vagrant Shutdown
\"
"
,
"shutdown_timeout"
:
"8h"
,
"ssh_wait_timeout"
:
"2h"
,
"shutdown_command"
:
"shutdown /s /t 10 /f /d p:4:1 /c
\"
Packer Shutdown
\"
"
,
"guest_os_type"
:
"Windows2012_64"
,
"disk_size"
:
61440
,
"guest_additions_attach"
:
"true"
,
...
...
@@ -52,15 +51,20 @@
]
}],
"provisioners"
:
[{
"type"
:
"file"
,
"source"
:
"./scripts/Windows8-RT-KB2842230-x64.msu"
,
"destination"
:
"/tmp/Windows8-RT-KB2842230-x64.msu"
},
{
"type"
:
"shell"
,
"remote_path"
:
"/tmp/script.bat"
,
"execute_command"
:
"{{
.Vars
}} cmd /c C:/Windows/Temp/script.bat"
,
"execute_command"
:
"{{.Vars}} cmd /c C:/Windows/Temp/script.bat"
,
"scripts"
:
[
"./scripts/virtualbox-tools.bat"
,
"./scripts/hotfix-KB2842230.bat"
,
"./scripts/vm-guest-tools.bat"
,
"./scripts/puppet.bat"
,
"./scripts/chef.bat"
,
"./scripts/chocolatey.bat"
]
},
{
"type"
:
"shell"
,
"inline"
:
[
"rm -rf /tmp/*"
]
}],
"post-processors"
:
[{
"type"
:
"vagrant"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment