Skip to content

Commit

Permalink
cygwin sshd autoinstallation more or less works now
Browse files Browse the repository at this point in the history
  • Loading branch information
jedi4ever committed May 23, 2011
1 parent a399528 commit 14b1847
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ boxes/*
pkg/*
*.box
.vagrant
virtualfloppy.vfd
30 changes: 30 additions & 0 deletions lib/veewee/session.rb
Expand Up @@ -526,6 +526,36 @@ def self.create_vm(boxname,force=false)
end
end

# Todo Check for java
# Todo check output of commands

# Check for floppy
unless @definition[:floppy_files].nil?
require 'tmpdir'
temp_dir=Dir.tmpdir
@definition[:floppy_files].each do |filename|
full_filename=full_filename=File.join(@definition_dir,boxname,filename)
FileUtils.cp("#{full_filename}","#{temp_dir}")
end
javacode_dir=File.expand_path(File.join(__FILE__,'..','..','java'))
floppy_file=File.join(@definition_dir,boxname,"virtualfloppy.vfd")
command="java -jar #{javacode_dir}/dir2floppy.jar '#{temp_dir}' '#{floppy_file}'"
puts "#{command}"
Veewee::Shell.execute("#{command}")

# Create floppy controller
command="#{@vboxcmd} storagectl '#{boxname}' --name 'Floppy Controller' --add floppy"
puts "#{command}"
Veewee::Shell.execute("#{command}")

# Attach floppy to machine (the vfd extension is crucial to detect msdos type floppy)
command="#{@vboxcmd} storageattach '#{boxname}' --storagectl 'Floppy Controller' --port 0 --device 0 --type fdd --medium '#{floppy_file}'"
puts "#{command}"
Veewee::Shell.execute("#{command}")

end


#Exec and system stop the execution here
Veewee::Shell.execute("#{command}")

Expand Down
116 changes: 116 additions & 0 deletions templates/windows-2008R2-amd64-experimental/Autounattend.xml
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<servicing></servicing>
<settings pass="windowsPE">
<component name="Microsoft-Windows-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">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>10000</Size>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Extend>false</Extend>
<Format>NTFS</Format>
<Letter>C</Letter>
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>Windows 2008R2</Label>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
<WillShowUI>OnError</WillShowUI>
</DiskConfiguration>
<UserData>
<ProductKey>
<WillShowUI>Never</WillShowUI>
</ProductKey>
<AcceptEula>true</AcceptEula>
<FullName>Vagrant Fullname</FullName>
<Organization>Vagrant Inc</Organization>
</UserData>
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>1</PartitionID>
</InstallTo>
<WillShowUI>OnError</WillShowUI>
<InstallToAvailablePartition>false</InstallToAvailablePartition>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows Server 2008 R2 SERVERSTANDARD</Value>
</MetaData>
</InstallFrom>
</OSImage>
</ImageInstall>
</component>
<component name="Microsoft-Windows-International-Core-WinPE" 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">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>en-US</UserLocale>
</component>
</settings>
<settings pass="oobeSystem">
<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">
<UserAccounts>
<AdministratorPassword>
<Value>dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<Description>Vagrant User</Description>
<DisplayName>vagrant</DisplayName>
<Group>administrators</Group>
<Name>vagrant</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Home</NetworkLocation>
</OOBE>
<AutoLogon>
<Password>
<Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
<PlainText>false</PlainText>
</Password>
<Username>administrator</Username>
<Enabled>true</Enabled>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>cmd.exe /c a:cygwin-sshd.bat</CommandLine>
<Description>Instal Cygwin SSH</Description>
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<ShowWindowsLive>false</ShowWindowsLive>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Security-SPP-UX" 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">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
</settings>
<cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverdatacenter.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
17 changes: 17 additions & 0 deletions templates/windows-2008R2-amd64-experimental/README.txt
@@ -0,0 +1,17 @@
Windows AutoUnattend.xml


Curl

http://curl.haxx.se/download.html

Fails -> http://curl.haxx.se/download/curl-7.21.0-win64-nossl.zip
Works -> http://www.paehl.com/open_source/?CURL_7.21.6

curl.exe http://cygwin.com/setup.exe -o setup.exe


http://cygwin.com/faq/faq.setup.html#faq.setup.cli


http://webcache.googleusercontent.com/search?q=cache:SjoPPpuQxuoJ:www.tcm.phy.cam.ac.uk/~mr349/cygwin_install.html+install+cygwin+ssh+commandline&cd=2&hl=nl&ct=clnk&gl=be&source=www.google.be
47 changes: 47 additions & 0 deletions templates/windows-2008R2-amd64-experimental/cygwin-sshd.bat
@@ -0,0 +1,47 @@
REM http://webcache.googleusercontent.com/search?q=cache:SjoPPpuQxuoJ:www.tcm.phy.cam.ac.uk/~mr349/cygwin_install.html+install+cygwin+ssh+commandline&cd=2&hl=nl&ct=clnk&gl=be&source=www.google.be

REM create the cygwin directory
cmd /c mkdir %SystemDrive%\cygwin
copy a:setup.exe %SystemDrive%\cygwin

REM goto a temp directory
cd %SystemDrive%\windows\temp

REM run the installation
cmd /c a:/setup.exe -q -R %SystemDrive%\cygwin -P openssh,openssl,curl,cygrunsrv,wget,rebase,vim -s http://cygwin.mirrors.pair.com

%SystemDrive%\cygwin\bin\bash -c 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin cygrunsrv -R sshd'

REM /bin/ash is the right shell for this command
cmd /c %SystemDrive%\cygwin\bin\ash -c /bin/rebaseall

cmd /c %SystemDrive%\cygwin\bin\bash -c 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin mkgroup -l'>%SystemDrive%\cygwin\etc\group

cmd /c %SystemDrive%\cygwin\bin\bash -c 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin mkpasswd -l'>%SystemDrive%\cygwin\etc\passwd

%SystemDrive%\cygwin\usr\bin\sleep 1

%SystemDrive%\cygwin\bin\bash -c 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin /usr/bin/ssh-host-config -y -c "ntsecbinmode tty" -w "abc&&123!!" '

%SystemDrive%\cygwin\usr\bin\sleep 2

cmd /c if exist %Systemroot%\system32\netsh.exe netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="c:\cygwin\usr\sbin\sshd.exe" SSHD enable=yes

cmd /c if exist %Systemroot%\system32\netsh.exe netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22

%SystemDrive%\cygwin\usr\bin\sleep 2

net start sshd

# http://myratnest.blogspot.com/2010/11/fun-cygwin-and-windows-2008-r2.html
# editrights -u sshd_server -a SeCreateTokenPrivilege

# http://superuser.com/questions/40545/upgrading-and-installing-packages-through-the-cygwin-command-line
#wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
#chmod +x apt-cyg
#mv apt-cyg /usr/local/bin/

# wget http://download.virtualbox.org/virtualbox/4.0.8/VirtualBox-4.0.8-71778-Win.exe
# chmod +x VirtualBox-4.0.8-71778-Win.exe
# ./VirtualBox-4.0.8-71778-Win.exe -extract
# ./VirtualBox-4.0.8-71778-Win.exe /extract /path .
18 changes: 18 additions & 0 deletions templates/windows-2008R2-amd64-experimental/definition.rb
@@ -0,0 +1,18 @@
Veewee::Session.declare({
:cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI', :hostiocache => 'off',
:os_type_id => 'Windows2008_64',
:iso_file => "7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
:iso_src => "",
:iso_md5 => "",
:floppy_files => ["Autounattend.xml","setup.exe","cygwin-sshd.bat"],
:iso_download_timeout => "1000",
:boot_wait => "10", :boot_cmd_sequence => [
],
:kickstart_port => "7122", :kickstart_timeout => "10000", :kickstart_file => "preseed.cfg",
:ssh_login_timeout => "10000", :ssh_user => "vagrant", :ssh_password => "vagrant", :ssh_key => "",
:ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
:shutdown_cmd => "shutdown -P now",
:postinstall_files => [], :postinstall_timeout => "10000"
})
Binary file not shown.

0 comments on commit 14b1847

Please sign in to comment.