Last active
March 31, 2021 18:01
-
-
Save mmguero/f22385dd2f8f4aeafcb66a08436cf3ac to your computer and use it in GitHub Desktop.
Vagrantfile: Windows 10 (StefanScherer/windows_10) with WSL Debian and Chocolatey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.define "vagrant-windows-10-preview" | |
config.vm.box = "StefanScherer/windows_10" | |
config.vm.communicator = "winrm" | |
# Admin username and password (see also WSL username/password setup in WSL_Debian_Setup.ps1) | |
config.winrm.username = "vagrant" | |
config.winrm.password = "vagrant" | |
config.vm.guest = :windows | |
config.windows.halt_timeout = 15 | |
# port forward WinRM and RDP | |
config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true | |
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true | |
config.vm.synced_folder "../../shared_files", "c:/vagrant_shared" | |
config.vm.provider :virtualbox do |vb, override| | |
vb.gui = true | |
vb.customize ["modifyvm", :id, "--memory", 8192] | |
vb.customize ["modifyvm", :id, "--cpus", 4] | |
vb.customize ["modifyvm", :id, "--vram", 256] | |
vb.customize ["modifyvm", :id, "--ioapic", "on"] | |
vb.customize ["modifyvm", :id, "--nestedpaging", "on"] | |
vb.customize ["modifyvm", :id, "--pae", "on"] | |
vb.customize ["modifyvm", :id, "--hwvirtex", "on"] | |
vb.customize ["modifyvm", :id, "--nested-hw-virt", "on"] | |
vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxsvga"] | |
vb.customize ["modifyvm", :id, "--accelerate2dvideo", "on"] | |
vb.customize ["modifyvm", :id, "--accelerate3d", "on"] | |
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"] | |
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] | |
vb.customize ["modifyvm", :id, "--usb", "on"] | |
vb.customize ["modifyvm", :id, "--usbehci", "on"] | |
vb.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "0", "--device", "1", "--type", "dvddrive", "--medium", "emptydrive"] | |
# vb.customize ["modifyvm", :id, "--audio", "pulse", "--audiocontroller", "hda"] # linux host | |
# vb.customize ["modifyvm", :id, "--audio", "coreaudio", "--audiocontroller", "hda"] # macOS host | |
# vb.customize ["modifyvm", :id, "--audio", "dsound", "--audiocontroller", "hda"] # windows host | |
end | |
# config.vm.provider "virtualbox" do |vb| | |
# vb.customize ["usbfilter", "add", "0", | |
# "--target", :id, | |
# "--name", "Any Cruzer Blade", | |
# "--product", "Cruzer Blade"] | |
# end | |
config.vm.provision "shell", inline: <<-STEP1 | |
New-Item -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows' -Name CloudContent | Out-Null | |
New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' -Name 'DisableWindowsConsumerFeatures' -PropertyType DWORD -Value '1' -Force | Out-Null | |
New-Item -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\' -Name 'Windows Search' | Out-Null | |
New-ItemProperty -Path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\Windows Search' -Name 'AllowCortana' -PropertyType DWORD -Value '0' -Force | Out-Null | |
Set-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\SQMClient\\Windows' CEIPEnable 0 | Out-Null | |
schtasks /Change /TN 'Microsoft\\Windows\\Customer Experience Improvement Program\\UsbCeip' /Disable | Out-Null | |
Get-AppxProvisionedPackage -online | select packagename | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.Office.Desktop") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.Office.OneNote") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.Xbox") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.SkypeApp") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.Zune") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.MicrosoftOffice") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "LinkedInforWindows") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxProvisionedPackage -online | %{if ($_.packagename -match "Microsoft.LinkedInforWindows") {$_ | Remove-AppxProvisionedPackage -AllUsers}} | |
Get-AppxPackage | select name | |
Get-AppxPackage | %{if ($_.name -match "Microsoft.zune") {$_ | Remove-AppxPackage -AllUsers}} | |
Get-AppxPackage | %{if ($_.name -match "microsoft.skypeapp") {$_ | Remove-AppxPackage -AllUsers}} | |
(New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items()| foreach { ($_).Verbs() | ?{$_.Name.Replace('&', '') -match 'From "Start" UnPin|Unpin from Start'} | %{$_.DoIt()} } | |
taskkill /f /im OneDrive.exe | |
C:/Windows/SysWOW64/OneDriveSetup.exe /uninstall | |
Enable-WindowsOptionalFeature -NoRestart -Online -FeatureName VirtualMachinePlatform | |
Enable-WindowsOptionalFeature -NoRestart -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
REG ADD "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power" /v HiberbootEnabled /t REG_DWORD /d "0" /f | |
STEP1 | |
config.vm.provision :reload | |
config.vm.provision "shell", inline: <<-STEP2 | |
Invoke-WebRequest -Uri https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -OutFile wsl_update_x64.msi -UseBasicParsing | |
New-Item -Path 'c:\\' -Name 'wsl_msi_extract' -ItemType 'directory' | |
msiexec /a wsl_update_x64.msi /qb TARGETDIR=C:\\wsl_msi_extract | |
Start-Sleep -s 10 | |
Copy-Item 'C:\\wsl_msi_extract\\System32\\lxss\\tools\\kernel' -Destination 'C:\\Windows\\System32\\lxss\\tools\\' | |
Remove-Item wsl_update_x64.msi | |
Remove-Item -recurse 'C:\\wsl_msi_extract' | |
wsl --set-default-version 1 | |
Invoke-WebRequest -Uri https://aka.ms/wsl-debian-gnulinux -OutFile Debian.appx -UseBasicParsing | |
Add-AppxPackage .\\Debian.appx | |
Remove-Item Debian.appx | |
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install -y chocolateygui pginafork chromium croc firefox 7zip.install sysinternals putty.install winscp.install keepass.install conemu sublimetext3 sumatrapdf.install hackfont | |
Invoke-WebRequest -Uri 'https://launchpad.net/veracrypt/trunk/1.24-update7/+download/VeraCrypt Portable 1.24-Update7.exe' -OutFile 'C:\\VeraCrypt Portable 1.24-Update7.exe' -UseBasicParsing | |
STEP2 | |
config.vm.provision "file", source: "./WSL_Debian_Setup.ps1", destination: "C:/WSL_Debian_Setup.ps1" | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start-Process "wsl.exe" -ArgumentList "--set-default-version 1" -Wait | |
Start-Process "debian.exe" -ArgumentList "install --root" -Wait | |
Start-Process "debian.exe" -ArgumentList 'run adduser vagrant --gecos ",,,," --disabled-password' -Wait | |
Start-Process "debian.exe" -ArgumentList "run echo 'vagrant:vagrant' | sudo chpasswd" -Wait | |
Start-Process "debian.exe" -ArgumentList "run usermod -aG sudo vagrant" -Wait | |
Start-Process "debian.exe" -ArgumentList "run apt-get update && apt-get -y dist-upgrade && apt-get -y install curl git bc tmux lsb-release" -Wait | |
Start-Process "debian.exe" -ArgumentList "config --default-user vagrant" -Wait | |
Start-Process "debian.exe" -ArgumentList "run mkdir -p ~/.config && git clone --recursive --depth 1 --single-branch -b master https://github.com/mmguero/config ~/.config/mmguero.config" -Wait | |
Start-Process "debian.exe" -ArgumentList "run rm -f ~/.bashrc && ln -s -r ~/.config/mmguero.config/bash/rc ~/.bashrc && ln -s -r ~/.config/mmguero.config/bash/aliases ~/.bash_aliases && ln -s -r ~/.config/mmguero.config/bash/functions ~/.bash_functions && ln -s -r ~/.config/mmguero.config/bash/rc.d ~/.bashrc.d && mkdir -p ~/.local/bin && ln -s -r ~/.config/mmguero.config/bash/context-color/context-color ~/.local/bin/ && ln -s -r ~/.config/mmguero.config/linux/tmux/tmux.conf ~/.tmux.conf && ln -s -r ~/.config/mmguero.config/git/gitconfig ~/.gitconfig" -Wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment