Skip to content

Instantly share code, notes, and snippets.

@Jawabiscuit
Last active June 20, 2022 20:18
Show Gist options
  • Save Jawabiscuit/6298e2c4bebe5ddde694df9d18d9451b to your computer and use it in GitHub Desktop.
Save Jawabiscuit/6298e2c4bebe5ddde694df9d18d9451b to your computer and use it in GitHub Desktop.
Choco install script for rez development

Rez Dev Box Install Script

Install Boxstarter/Chocolatey

Open an elevated powershell (not pwsh) terminal

Install boxstarter (boxstarter installs chocolatey)

Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1')); Get-Boxstarter -Force;

Run ChocoInstall script

Sets up machine with everything except rez

# Raw URL
$installScriptUri = "https://gist.githubusercontent.com/Jawabiscuit/6298e2c4bebe5ddde694df9d18d9451b/raw/381fa40b3b4963bc43519ca9c279acb41b09a3bb/ChocoInstall-RezDevBox.ps1"

# Execute
Invoke-Expression ((New-Object net.webclient).DownloadString($installScriptUri))

Manual Steps

<#
    Create key. Manually copy to Github
#>
ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N '""'

Win32 long paths should be enabled:

  1. Open the Local Group Policy Editor
  2. Navigate to: Local Computer Policy / Computer Configuration / Administrative Templates / System / Filesystem
  3. Double click on "Enable Win32 long paths"
  4. Tick "Enabled"
  5. Click "Apply"

Disable Microsoft Store python shortcut

  1. Settings / Manage App Execution Aliases
  2. Disable App Installer for python.exe and python3.exe

Python 3

Instead of Python 2 which is the default on this system, try switching to Python 3.

  1. Open environment variable settings
  2. Remove Python2 paths in user PATH
  3. Reorder Python3 paths first in system PATH

Install rez

<#
Download and install boxstarter from boxstarter.org
This is an example configuration meant to be modified extensively
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1'));
Get-Boxstarter -Force
Boxstarter installs chocolatey
Be sure to:
- Run this script in a normal powershell, not pwsh
- Change the variable defaults below if your name is not Jonas Avrin
- Remove or modify configurations as they are likely different from person to person
#>
$USERNAME = $env:USERNAME # Change this if necessary (javrin)
$EMAIL = $env:EMAIL # Change this to your email (jawabiscuit@users.noreply.github.com)
$GH_USERNAME = $env:GITHUB_USERNAME # Change this to your github username (jawabiscuit)
Disable-UAC
# Allow execution of powershell scripts
Update-ExecutionPolicy Unrestricted
# Silencing progress to make downloads faster
$ProgressPreference = "SilentlyContinue"
# No confirmation i.e. --yes
choco feature enable --name=allowGlobalConfirmation
# Disable Microsoft and Windows update
# Disable-MicrosoftUpdate
<#
System configuration
#>
Write-Host "Initial system configuration..." -ForegroundColor Green
# Regional Settings
& "$env:windir\system32\tzutil.exe" /s "Eastern Standard Time"
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sShortDate -Value 'dd MM yy'
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sShortTime -Value 'HH:mm tt'
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sTimeFormat -Value 'HH:mm:ss tt'
# Enable developer mode on the system
Set-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense -Value 1
# Turn off screensaver
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0
# Disable UAC popups
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableLUA -Value 0 -Force
# Update help
# Update-Help
Set-StartScreenOptions -EnableBootToDesktop
<#
Windows configuration
#>
Write-Host "Setting Windows options..." -ForegroundColor Green
## File Explorer
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -DisableOpenFileExplorerToQuickAccess -DisableShowRecentFilesInQuickAccess -DisableShowFrequentFoldersInQuickAccess -EnableExpandToOpenFolder -EnableShowRibbon
# Other params: -Dock Bottom -Combine Always -AlwaysShowIconsOn -MultiMonitorOn -MultiMonitorMode All -MultiMonitorCombine Always
Set-BoxstarterTaskbarOptions -Size Small
<#
Chocolatey
#>
Write-Host "Installing tools and utilities..." -ForegroundColor Green
# Sys admin utils -- https://docs.microsoft.com/en-us/sysinternals/
choco install --limitoutput sysinternals
choco install --limitoutput git.install -params "'/GitAndUnixToolsOnPath /NoAutoCrlf /DefaultBranchName:main /Symlinks'"
choco install --limitoutput python
choco install --limitoutput python2
choco install --limitoutput 7zip.install
choco install --limitoutput googlechrome
choco install --limitoutput powershell-core
choco install --limitoutput ripgrep
RefreshEnv
<#
Git Config
#>
Write-Host "Configuring git..." -ForegroundColor Green
[Environment]::SetEnvironmentVariable("HOME", $env:USERPROFILE, "User")
Set-Item "env:\PATH" "$env:PROGRAMFILES\Git\bin;$env:PATH"
git config --global user.name $USERNAME
git config --global user.email $EMAIL
git config --global core.autocrlf false
git config --global core.filemode false
git config --global core.excludesfile $env:USERPROFILE\.gitignore
git config --global github.user $GH_USERNAME
git config --global advise.detachedHead false
<#
Powershell Utilities
#>
Write-Host "Installing Powershell utilities..." -ForegroundColor Green
# Install NuGet -- This needs to come first otherwise user confirmation
# is necessary and difficult to avoid.
Write-Output "Installing NuGet package provider"
Install-PackageProvider -Name NuGet -Scope CurrentUser -Force -Verbose
Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted'
# Install PowershellGet
Write-Output "Installing PowershellGet"
Install-Package -Name PowershellGet -Force -Verbose
# Install PackageManagement
Write-Output "Installing PackageManagement"
Install-Package -Name PackageManagement -MinimumVersion 1.4.7 -Force -Confirm:$false -Source PSGallery -Verbose
## Modules
Install-Module -Name 7Zip4Powershell -AllowClobber -Force
Install-Module -Name Carbon -AllowClobber -Force
Install-Module -Name PowerShellHumanizer -AllowClobber -Force
Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Untrusted'
<#
Utilities
Write-Host "Installing system utilities..." -ForegroundColor Green
#>
<#
SSH
#>
Write-Host "Installing and configuring SSH..." -ForegroundColor Green
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
# Start the sshd service
Start-Service sshd
# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
} else {
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
}
<#
Rez
#>
Write-Host "Rez configuration..." -ForegroundColor Green
# Enable remote symlinks
fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1
# Environment
if ([Environment]::GetEnvironmentVariable("PYTHONIOENCODING", "Machine").Count -eq "0") {
[Environment]::SetEnvironmentVariable("PYTHONIOENCODING", "UTF-8", "Machine")
}
if ([Environment]::GetEnvironmentVariable("PYTHONDONTWRITEBYTECODE", "Machine").Count -eq "0") {
[Environment]::SetEnvironmentVariable("PYTHONDONTWRITEBYTECODE", "1", "Machine")
}
if ([Environment]::GetEnvironmentVariable("SHELL", "Machine").Count -eq "0") {
[Environment]::SetEnvironmentVariable("SHELL", "$env:PROGRAMFILES\Git\bin\bash.exe", "Machine")
}
# Use system Python default, experiment changing it to Python 3
# [Environment]::SetEnvironmentVariable("PATH", "C:\Python27;C:\Python27\Scripts;$env:PATH", "User")
<#
Cleanup
#>
Write-Host "Cleaning up..." -ForegroundColor Green
# Revert No confirmation feature
choco feature disable --name=allowGlobalConfirmation
<#
Windows Update
# Enable Windows update
#>
Write-Host "Enabling Windows Update..." -ForegroundColor Green
# Enable Microsoft Update
Enable-MicrosoftUpdate
Install-WindowsUpdate -AcceptEula
# Re-enable UAC
Enable-UAC
Write-Host "Finished." -ForegroundColor Green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment