From 79bbe5bdc4867088b3e074f9610932f8e4e192c2 Mon Sep 17 00:00:00 2001 From: Yosef Durr Date: Tue, 18 Sep 2018 09:37:18 -0700 Subject: [PATCH] Started a demoscripts folder, refactored some helper scripts (#70) * moving all recipes to dynamically find helper scripts * started to a devops_azure script * re-organizing some existing scripts * updated Readme known issues --- README.md | 3 +- demos/chocolateyfest2018.ps1 | 42 ++++++++++++++ dev_ml_wsl.ps1 | 8 +-- dev_web.ps1 | 9 ++- dev_web_nodejs.ps1 | 7 +-- devops_azure.ps1 | 38 +++++++++++++ scripts/Browsers.ps1 | 3 + scripts/Docker.ps1 | 2 + scripts/GetMLPythonSamplesOffGithub.ps1 | 6 -- scripts/HyperV.ps1 | 1 + scripts/{VirtualizationTools.ps1 => WSL.ps1} | 59 ++++++++++---------- 11 files changed, 125 insertions(+), 53 deletions(-) create mode 100644 demos/chocolateyfest2018.ps1 create mode 100644 devops_azure.ps1 create mode 100644 scripts/Browsers.ps1 create mode 100644 scripts/Docker.ps1 delete mode 100644 scripts/GetMLPythonSamplesOffGithub.ps1 create mode 100644 scripts/HyperV.ps1 rename scripts/{VirtualizationTools.ps1 => WSL.ps1} (60%) diff --git a/README.md b/README.md index eb98ab0..cf53ed8 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ with a non-blank password. Use this user going forward. For more info on WSL ple 2. If you're a Node.js contributor working on Node.js core, please see the [Node.js Bootstrapping Guide](https://github.com/nodejs/node/tree/master/tools/bootstrap) or [click here to run](http://boxstarter.org/package/nr/url?https://raw.githubusercontent.com/nodejs/node/master/tools/bootstrap/windows_boxstarter). ## Known issues -- Reboot is not always logging you back in to resume the script. This is being tracked [here](https://github.com/chocolatey/boxstarter/issues/318). If you experience this please login manually and the script will continue running. +- The Boxstarter ClickOnce installer does not work when using Chrome. This issue is being tracked [here](https://github.com/chocolatey/boxstarter/issues/345). Please use Edge to run the ClickOnce installer. +- Reboot is not always logging you back in to resume the script. This is being tracked [here](https://github.com/chocolatey/boxstarter/issues/318). The workaround is to login manually and the script will continue running. - There have been reports of Windows 1803 not successfully launching Boxstarter via the web launcher. See this issue for details: https://github.com/chocolatey/boxstarter/issues/301 ## Working with Chocolatey in an organization? diff --git a/demos/chocolateyfest2018.ps1 b/demos/chocolateyfest2018.ps1 new file mode 100644 index 0000000..2b81e80 --- /dev/null +++ b/demos/chocolateyfest2018.ps1 @@ -0,0 +1,42 @@ +# Description: Boxstarter Script +# Author: Microsoft +# Common settings for web dev + +Disable-UAC + +# Get the base URI path from the ScriptToCall value +$bstrappackage = "-bootstrapPackage" +$helperUri = $Boxstarter['ScriptToCall'] +$strpos = $helperUri.IndexOf($bstrappackage) +$helperUri = $helperUri.Substring($strpos + $bstrappackage.Length) +$helperUri = $helperUri.TrimStart("'", " ") +$helperUri = $helperUri.TrimEnd("'", " ") +$helperUri = $helperUri.Substring(0, $helperUri.LastIndexOf("/")) +$helperUri += "/scripts" +write-host "helper script base URI is $helperUri" + +function executeScript { + Param ([string]$script) + write-host "executing $helperUri/$script ..." + iex ((new-object net.webclient).DownloadString("$helperUri/$script")) +} + +#--- Setting up Windows --- +executeScript "FileExplorerSettings.ps1"; +executeScript "SystemConfiguration.ps1"; +executeScript "CommonDevTools.ps1"; +executeScript "RemoveDefaultApps.ps1"; +executeScript "WSL.ps1"; +executeScript "VirtualizationTools.ps1"; + +#--- Browsers --- +choco install -y googlechrome +choco install -y firefox + +# TODO: Expand on tools/configuration options here +# Tools inside WSL +# Azure CLI + +Enable-UAC +Enable-MicrosoftUpdate +Install-WindowsUpdate -acceptEula diff --git a/dev_ml_wsl.ps1 b/dev_ml_wsl.ps1 index 9526a05..b744dd3 100644 --- a/dev_ml_wsl.ps1 +++ b/dev_ml_wsl.ps1 @@ -26,16 +26,14 @@ executeScript "SystemConfiguration.ps1"; executeScript "FileExplorerSettings.ps1"; executeScript "RemoveDefaultApps.ps1"; executeScript "CommonDevTools.ps1"; -executeScript "VirtualizationTools.ps1"; -executeScript "GetMLPythonSamplesOffGithub.ps1"; +executeScript "HyperV.ps1"; +executeScript "WSL.ps1"; write-host "Installing tools inside the WSL distro..." -Ubuntu1804 run apt update -Ubuntu1804 run apt upgrade -y -## Install Python tools Ubuntu1804 run apt install python2.7 python-pip -y Ubuntu1804 run apt install python-numpy python-scipy -y Ubuntu1804 run pip install pandas + write-host "Finished installing tools inside the WSL distro" Enable-UAC diff --git a/dev_web.ps1 b/dev_web.ps1 index 630eb18..2d001c5 100644 --- a/dev_web.ps1 +++ b/dev_web.ps1 @@ -26,16 +26,15 @@ executeScript "FileExplorerSettings.ps1"; executeScript "SystemConfiguration.ps1"; executeScript "CommonDevTools.ps1"; executeScript "RemoveDefaultApps.ps1"; -executeScript "VirtualizationTools.ps1"; +executeScript "HyperV.ps1"; +executeScript "Docker.ps1"; +executeScript "WSL.ps1"; +executeScript "Browsers.ps1"; #--- Tools --- code --install-extension msjsdiag.debugger-for-chrome code --install-extension msjsdiag.debugger-for-edge -#--- Browsers --- -choco install -y googlechrome -choco install -y firefox - #--- Microsoft WebDriver --- choco install -y microsoftwebdriver diff --git a/dev_web_nodejs.ps1 b/dev_web_nodejs.ps1 index bfe60a9..55ba0be 100644 --- a/dev_web_nodejs.ps1 +++ b/dev_web_nodejs.ps1 @@ -26,11 +26,8 @@ executeScript "SystemConfiguration.ps1"; executeScript "FileExplorerSettings.ps1"; executeScript "RemoveDefaultApps.ps1"; executeScript "CommonDevTools.ps1"; -executeScript "VirtualizationTools.ps1"; - -#--- Browsers --- -choco install -y Firefox -choco install -y Googlechrome +executeScript "WSL.ps1"; +executeScript "Browsers.ps1"; #--- Tools --- code --install-extension msjsdiag.debugger-for-chrome diff --git a/devops_azure.ps1 b/devops_azure.ps1 new file mode 100644 index 0000000..285510d --- /dev/null +++ b/devops_azure.ps1 @@ -0,0 +1,38 @@ +# Description: Boxstarter Script +# Author: Microsoft +# Common settings for azure devops + +Disable-UAC + +# Get the base URI path from the ScriptToCall value +$bstrappackage = "-bootstrapPackage" +$helperUri = $Boxstarter['ScriptToCall'] +$strpos = $helperUri.IndexOf($bstrappackage) +$helperUri = $helperUri.Substring($strpos + $bstrappackage.Length) +$helperUri = $helperUri.TrimStart("'", " ") +$helperUri = $helperUri.TrimEnd("'", " ") +$helperUri = $helperUri.Substring(0, $helperUri.LastIndexOf("/")) +$helperUri += "/scripts" +write-host "helper script base URI is $helperUri" + +function executeScript { + Param ([string]$script) + write-host "executing $helperUri/$script ..." + iex ((new-object net.webclient).DownloadString("$helperUri/$script")) +} + +#--- Setting up Windows --- +executeScript "FileExplorerSettings.ps1"; +executeScript "SystemConfiguration.ps1"; +executeScript "RemoveDefaultApps.ps1"; +executeScript "WSL.ps1"; +executeScript "HyperV.ps1"; +executeScript "Docker.ps1"; +executeScript "Browsers.ps1"; + +# TODO: Expand on tools/configuration options here +# Azure CLI, Azure PS, Azure SDK, Ansible, TerraForms + +Enable-UAC +Enable-MicrosoftUpdate +Install-WindowsUpdate -acceptEula diff --git a/scripts/Browsers.ps1 b/scripts/Browsers.ps1 new file mode 100644 index 0000000..2ab3b68 --- /dev/null +++ b/scripts/Browsers.ps1 @@ -0,0 +1,3 @@ +#--- Browsers --- +choco install -y googlechrome +choco install -y firefox diff --git a/scripts/Docker.ps1 b/scripts/Docker.ps1 new file mode 100644 index 0000000..d4d0b35 --- /dev/null +++ b/scripts/Docker.ps1 @@ -0,0 +1,2 @@ +choco install -y docker-for-windows +choco install -y vscode-docker diff --git a/scripts/GetMLPythonSamplesOffGithub.ps1 b/scripts/GetMLPythonSamplesOffGithub.ps1 deleted file mode 100644 index a968b46..0000000 --- a/scripts/GetMLPythonSamplesOffGithub.ps1 +++ /dev/null @@ -1,6 +0,0 @@ - -write-host "Downloading Python ML samples to your desktop ..." - -Update-SessionEnvironment -cd $env:USERPROFILE\desktop -git clone https://github.com/Microsoft/Dev-Advocacy-Samples diff --git a/scripts/HyperV.ps1 b/scripts/HyperV.ps1 new file mode 100644 index 0000000..1625188 --- /dev/null +++ b/scripts/HyperV.ps1 @@ -0,0 +1 @@ +choco install -y Microsoft-Hyper-V-All -source windowsFeatures diff --git a/scripts/VirtualizationTools.ps1 b/scripts/WSL.ps1 similarity index 60% rename from scripts/VirtualizationTools.ps1 rename to scripts/WSL.ps1 index 786ec6c..80de0a8 100644 --- a/scripts/VirtualizationTools.ps1 +++ b/scripts/WSL.ps1 @@ -1,31 +1,28 @@ - -choco install -y Microsoft-Windows-Subsystem-Linux -source windowsfeatures -choco install -y Microsoft-Hyper-V-All -source windowsFeatures -# alternative to above: Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName Microsoft-Windows-Subsystem-Linux -# alternative to above: Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName Microsoft-Hyper-V -choco install -y docker-for-windows -choco install -y vscode-docker - - -#--- Ubuntu --- -Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu.appx -UseBasicParsing -Add-AppxPackage -Path ~/Ubuntu.appx -# run the distro once and have it install locally with a blank root user -Ubuntu1804 install --root - -<# -NOTE: Other distros can be scripted the same way for example: - -#--- SLES --- -# Install SLES Store app -Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile ~/SLES.appx -UseBasicParsing -Add-AppxPackage -Path ~/SLES.appx -# Launch SLES -sles-12.exe - -# --- openSUSE --- -Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile ~/openSUSE.appx -UseBasicParsing -Add-AppxPackage -Path ~/openSUSE.appx -# Launch openSUSE -opensuse-42.exe -#> +choco install -y Microsoft-Windows-Subsystem-Linux -source windowsfeatures + +#--- Ubuntu --- +# TODO: Move this to choco install once --root is included in that package +Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile ~/Ubuntu.appx -UseBasicParsing +Add-AppxPackage -Path ~/Ubuntu.appx +# run the distro once and have it install locally with root user, unset password +Ubuntu1804 install --root +Ubuntu1804 run apt update +Ubuntu1804 run apt upgrade -y + +<# +NOTE: Other distros can be scripted the same way for example: + +#--- SLES --- +# Install SLES Store app +Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile ~/SLES.appx -UseBasicParsing +Add-AppxPackage -Path ~/SLES.appx +# Launch SLES +sles-12.exe + +# --- openSUSE --- +Invoke-WebRequest -Uri https://aka.ms/wsl-opensuse-42 -OutFile ~/openSUSE.appx -UseBasicParsing +Add-AppxPackage -Path ~/openSUSE.appx +# Launch openSUSE +opensuse-42.exe +#> +