├── .gitignore ├── CreateVM.ps1 ├── FetchOrigin.bat ├── FetchUpstream.bat ├── Gemfile.local ├── HyperV ├── ImportMasters.ps1 ├── PurgeVMS.ps1 └── SetupHyperVNetworking.ps1 ├── ImportMasterVMs.ps1 ├── LICENSE ├── LocalRM.ps1 ├── Public-Network-Detector.txt ├── RemoveVM.ps1 ├── RubyCerts.ps1 ├── Start-Portainer.ps1 ├── archive ├── Install-cpp-build.ps1 ├── InstallDockerEE.ps1 ├── PuppetDevEnv │ ├── Dockerfile │ ├── build-context.ps1 │ ├── build-docker.ps1 │ └── docker_file-build.ps1 ├── RemoveWatches.ps1 ├── SophosBeGone.ps1 ├── bi-nobeaker.sh ├── config-pe-client-tools.ps1 ├── create-pdk-shell.ps1 ├── devpooler.bat ├── jenkins-experimental.ps1 ├── pooler-local.bat ├── pooler.bat ├── rubypwsh │ ├── Dockerfile │ └── build.bat └── uber-ruby-installer.ps1 ├── base16-bright.json ├── be.cmd ├── be.sh ├── bi.cmd ├── bi.sh ├── bq.cmd ├── bq.sh ├── bundle.ps1 ├── convertallcrlf.txt ├── default-windowspowershell-profile.ps1 ├── default_starship.toml ├── dockruby.cmd ├── getpr.ps1 ├── lastdocker.ps1 ├── powerline.psm1 ├── powerpoint.ps1 ├── pryme.cmd ├── pryme.sh ├── scpsync-ubuntu.script ├── scpsync-ubunutu.ps1 ├── scpsync.ps1 ├── scpsync.script ├── ssh.cmd ├── update-system-gems.bat └── uru-save.cmd /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | context/ 3 | portainer_data/ 4 | bin/ 5 | -------------------------------------------------------------------------------- /CreateVM.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [parameter(Position=0)] 3 | [string]$VMName = '', 4 | 5 | [parameter(Position=1)] 6 | [string]$Template = '', 7 | 8 | [string]$RemoteUsername = 'Administrator', 9 | [string]$RemotePassword = 'Password1' 10 | ) 11 | $ErrorActionPreference = 'Stop' 12 | 13 | $DiskRoot = 'C:\HyperV\Disks' 14 | 15 | $Templates = @{ 16 | 'Server2012R2' = @{ 17 | 'ParentDisk' = 'Server 2012 R2 - Master.vhdx' 18 | 'DiskType' = 'vhdx' 19 | 'Memory' = 4096 * 1024 * 1024 20 | 'VMSwitch' = 'Internal (with NAT)' 21 | 'Generation' = 2 22 | 'vCPU' = 2 23 | } 24 | 'Server2016RS1' = @{ 25 | 'ParentDisk' = 'Server 2016 RTM - Master.vhdx' 26 | 'DiskType' = 'vhdx' 27 | 'Memory' = 4096 * 1024 * 1024 28 | 'VMSwitch' = 'Internal (with NAT)' 29 | 'Generation' = 2 30 | 'vCPU' = 2 31 | } 32 | 'Ubuntu1604' = @{ 33 | 'ParentDisk' = 'Ubuntu 16.04 - Master.vhdx' 34 | 'DiskType' = 'vhdx' 35 | 'Memory' = 4096 * 1024 * 1024 36 | 'VMSwitch' = 'Internal (with NAT)' 37 | 'Generation' = 1 38 | 'vCPU' = 2 39 | } 40 | 'Ubuntu1604Desktop' = @{ 41 | 'ParentDisk' = 'Ubuntu 16.04 Desktop - Master.vhdx' 42 | 'DiskType' = 'vhdx' 43 | 'Memory' = 4096 * 1024 * 1024 44 | 'VMSwitch' = 'Internal (with NAT)' 45 | 'Generation' = 1 46 | 'vCPU' = 2 47 | } 48 | 'Ubuntu1804Desktop' = @{ 49 | 'ParentDisk' = 'Ubuntu 18.04 Desktop - Master.vhdx' 50 | 'DiskType' = 'vhdx' 51 | 'Memory' = 4096 * 1024 * 1024 52 | 'VMSwitch' = 'Internal (with NAT)' 53 | 'Generation' = 1 54 | 'vCPU' = 2 55 | 'EnhancedSessionTransportType' = 'HvSocket' 56 | } 57 | 'WindowsContainerHost' = @{ 58 | 'ParentDisk' = 'Server 2016 RTM - Master.vhdx' 59 | 'DiskType' = 'vhdx' 60 | 'Memory' = 4096 * 1024 * 1024 61 | 'VMSwitch' = 'Internal (with NAT)' 62 | 'Generation' = 2 63 | 'vCPU' = 2 64 | 'PostCommands' = @( 65 | 'netsh advfirewall firewall add rule name="All Incoming" dir=in action=allow enable=yes interfacetype=any profile=any localip=any remoteip=any', 66 | 'netsh advfirewall firewall add rule name="All Outgoing" dir=out action=allow enable=yes interfacetype=any profile=any localip=any remoteip=any', 67 | 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force', 68 | 'Install-Module -Name DockerMsftProvider -Repository PSGallery -Force', 69 | 'Install-Package -Name docker -ProviderName DockerMsftProvider -Force', 70 | "`"{`n ```"hosts```": [```"tcp://0.0.0.0:2375```", ```"npipe://```"]`n ```"insecure-registries```": [```"10.0.0.0/8```"]`n }`" | Set-Content -Path 'C:\ProgramData\docker\config\daemon.json' -Encoding ASII" 71 | 'Restart-Computer -Force', 72 | 'docker --version', 73 | 'docker network create -d transparent TransparentNetworkDHCP', 74 | 'docker network create -d transparent --subnet=192.168.200.0/24 --gateway=192.168.200.1 TransparentNetwork', 75 | 'docker pull microsoft/nanoserver', 76 | 'docker pull microsoft/windowsservercore' 77 | ) 78 | } 79 | } 80 | 81 | # TODO Add portainer to script 82 | # https://hub.docker.com/r/portainer/portainer/tags/ 83 | # https://portainer.readthedocs.io/en/latest/deployment.html#deployment 84 | # https://github.com/portainer/portainer/releases 85 | 86 | # BEGIN Helper Functions 87 | Function Get-IPFromVMName($VMName, $timeout = 120) { 88 | $itsIP = $null 89 | $attempt = [int]($timeout / 2) 90 | Write-Host "Waiting $($attempt*2) seconds for IP..." 91 | do { 92 | $ips = Get-VM -Name $VMName | ?{$_.ReplicationMode -ne "Replica"} | Select -ExpandProperty NetworkAdapters | Select IPAddresses 93 | $itsIP = $ips.IPAddresses | ? { $_ -like '192.168.200.*' } 94 | $attempt-- 95 | if ($itsIP -eq $null -and $attempt -ne 0) { Start-Sleep -Seconds 2 } 96 | } until (($attempt -le 0) -or ($itsIP -ne $null)) 97 | if ($itsIP -ne $null) { Write-Output $itsIP } 98 | } 99 | # END Helper Functions 100 | 101 | # Get VM Name if not supplied 102 | while ($VMName -eq '') { 103 | $VMName = Read-Host -Prompt "Enter VM Name" 104 | } 105 | 106 | # Get Template Name if not supplied 107 | while (-not ($Templates.ContainsKey($Template))) { 108 | Write-Host "Templates:" 109 | $Templates.GetEnumerator() | Sort-Object Key | % { 110 | Write-Host " - $($_.Key)" 111 | } 112 | 113 | $Template = Read-Host -Prompt "Enter Template Name" 114 | } 115 | 116 | $VMTemplate = $Templates."$Template" 117 | $VMDiskName = Join-Path -Path $DiskRoot -ChildPath "$($VMName).$($VMTemplate.DiskType)" 118 | $RootVMDisk = Join-Path -Path $DiskRoot -ChildPath "$($VMTemplate.ParentDisk)" 119 | 120 | # Cleanup 121 | Get-VM -Name $VMName -ErrorAction 'SilentlyContinue' | Remove-VM -Name $VMName -Confirm:$false -Force | out-Null 122 | If (Test-Path -Path $VMDiskName) { Remove-Item -Path $VMDiskName -Confirm:$false -Force | Out-Null } 123 | 124 | # Create the VM 125 | $newVM = New-VM -Name $VMName -MemoryStartupBytes $VMTemplate.Memory -Generation $VMTemplate.Generation ` 126 | -NoVHD -SwitchName $VMTemplate.VMSwitch -Confirm:$false | 127 | Set-VMProcessor -Count $VMTemplate.vCPU 128 | 129 | # Create the disk 130 | $newDisk = New-VHD -Path $VMDiskName -ParentPath $RootVMDisk -Differencing 131 | # Attach the disk 132 | Add-VMHardDiskDrive -VMName $VMName -Path $VMDiskName | Out-Null 133 | 134 | # Set the Boot Order... 135 | if ($VMTemplate.Generation -eq '2') { 136 | Write-Host "Setting first boot device to Disk..." 137 | Set-VMFirmware -VMName $VMName -FirstBootDevice (Get-VMHardDiskDrive -VMName $VMName) 138 | } 139 | 140 | # Disable automatic checkpoints 141 | Set-Vm -Name $VMName -AutomaticCheckpointsEnabled:$false | Out-Null 142 | 143 | # Set Session type 144 | if ($VMTemplate.EnhancedSessionTransportType -ne $null) { 145 | Set-VM -Name $VMName -EnhancedSessionTransportType $VMTemplate.EnhancedSessionTransportType 146 | } 147 | 148 | # Start the VM 149 | Write-Host "Starting the VM..." 150 | Start-VM -Name $VMName -AsJob | Out-Null 151 | 152 | $vmIP = Get-IPFromVMName -VMName $VMName 153 | Write-Host $vmIP 154 | 155 | # Run any Post Commands if specified 156 | If ($VMTemplate.PostCommands -ne $null) { 157 | $secpasswd = ConvertTo-SecureString $RemotePassword -AsPlainText -Force 158 | $winrmCreds = New-Object System.Management.Automation.PSCredential ($RemoteUsername, $secpasswd) 159 | 160 | $VMTemplate.PostCommands | % { 161 | # Wait for WinRM to become available (120s timeout) 162 | $attempt = 60 163 | Write-Host "Waiting $($attempt*2) seconds for WinRM..." 164 | do { 165 | $isUp = $false 166 | try { 167 | Test-WSMan -Computer $vmIP -Credential $winrmCreds -Authentication Default | Out-Null 168 | $isUp = $true 169 | } 170 | catch [System.Exception] { 171 | $isUp = $false 172 | } 173 | $attempt-- 174 | if ((!$isUp) -and $attempt -ne 0) { Start-Sleep -Seconds 2 } 175 | } until (($attempt -le 0) -or ($isUp)) 176 | $cmd = $_ 177 | Write-Host "Runnning command: $cmd ..." 178 | try { 179 | Invoke-Command -ComputerName $vmIP -Credential $winrmCreds -ArgumentList @($cmd) -ScriptBlock { 180 | param($cmd) 181 | Invoke-Expression -Command $cmd 182 | } 183 | } 184 | catch [System.Exception] { 185 | Write-Warning "REMOTE ERROR: $_" 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /FetchOrigin.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | IF [%1]==[] ( 4 | ECHO FetchOrigin requires a branch name 5 | EXIT /B 1 6 | ) 7 | 8 | SETLOCAL 9 | 10 | SET BRANCH=%1 11 | 12 | CALL git checkout %BRANCH% 13 | 14 | CALL git fetch origin %BRANCH% --prune 15 | 16 | CALL git pull origin %BRANCH% --ff-only 17 | 18 | Exit /B 0 19 | -------------------------------------------------------------------------------- /FetchUpstream.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | IF [%1]==[] ( 4 | ECHO FetchUpstream requires a branch name 5 | EXIT /B 1 6 | ) 7 | 8 | SETLOCAL 9 | 10 | SET BRANCH=%1 11 | 12 | CALL git checkout %BRANCH% 13 | 14 | CALL git fetch upstream --prune 15 | 16 | CALL git pull upstream %BRANCH% --ff-only 17 | 18 | SET /P DoPush=Push to origin (Y/N)? : 19 | 20 | IF [%DoPush%] == [y] ( GOTO DoPush) 21 | IF [%DoPush%] == [Y] ( GOTO DoPush) 22 | 23 | Exit /B 0 24 | 25 | :DoPush 26 | 27 | CALL git push origin %BRANCH% 28 | -------------------------------------------------------------------------------- /Gemfile.local: -------------------------------------------------------------------------------- 1 | gem 'fuubar' 2 | 3 | if RUBY_VERSION == "1.8.7" 4 | gem 'debugger' 5 | elsif RUBY_VERSION =~ /^2\.[01]/ 6 | gem "byebug", "~> 9.0.0" 7 | gem "pry-byebug" 8 | elsif RUBY_VERSION =~ /^2\.[23456789]/ 9 | gem "pry-byebug" 10 | else 11 | gem "pry-debugger" 12 | # gem 'ruby-debug' 13 | end 14 | 15 | if RUBY_VERSION =~ /^2\.[6789]/ 16 | gem "pry-stack_explorer" 17 | else 18 | gem "pry-stack_explorer", "~>0.4.0" 19 | end 20 | -------------------------------------------------------------------------------- /HyperV/ImportMasters.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' 2 | 3 | Function Expand-VMConfig ($VMConfig) { 4 | $tempVM = (Compare-VM -Copy -Path $VMConfig -GenerateNewID).VM 5 | 6 | write-host 'VM Configuration Data' 7 | write-host '=====================' 8 | $tempVM | Select * 9 | 10 | write-host 'VM Network Adapters' 11 | write-host '=====================' 12 | $tempVM.NetworkAdapters 13 | 14 | write-host 'VM Hard Drives' 15 | write-host '=====================' 16 | $tempVM.HardDrives 17 | 18 | write-host 'VM DVD Drives' 19 | write-host '=====================' 20 | $tempVM.DVDDrives 21 | 22 | write-host 'VM Floppy Drive' 23 | write-host '=====================' 24 | $tempVM.FloppyDrive 25 | 26 | write-host 'VM Fibre Channel' 27 | write-host '=====================' 28 | $tempVM.FibreChannelHostBusAdapters 29 | 30 | write-host 'VM COM1' 31 | write-host '=====================' 32 | $tempVM.ComPort1 33 | 34 | write-host 'VM COM2' 35 | write-host '=====================' 36 | $tempVM.ComPort2 37 | } 38 | 39 | $rootPath = 'C:\HyperV\VMs\Virtual Machines\' 40 | 41 | $currentVMs = (Get-VM | % { Write-Output $_.Id.ToString().ToLower() }) 42 | if ($null -eq $currentVMs) { $currentVMs = @() } 43 | if ($currentVMs.GetType().ToString() -ne 'System.Object[]') { $currentVMs = @($currentVMs) } 44 | 45 | # Write-Host ($currentVMs | COnvertTo-JSON) -ForegroundColor Magenta 46 | 47 | Function Import-Master($VMConfig) { 48 | try { 49 | $CompareResult = Compare-VM -Copy -Path $VMConfig.FullName -GenerateNewID -ErrorAction Stop 50 | $tempVM = $CompareResult.VM 51 | 52 | if ($CompareResult.Incompatibilities.Count -gt 0) { 53 | Write-Host "VM (${VMConfig}) $($tempVM.VMName) has Incompatibilities..." -ForegroundColor Red 54 | Write-Host ($CompareResult.Incompatibilities | Select-Object Message) -ForegroundColor Red 55 | return 56 | } 57 | } catch { 58 | Write-Host "Unable to query ${VMconfig.FullName}" -ForegroundColor Red 59 | return 60 | } 61 | 62 | $descriptiveName = "(${VMConfig}) $($tempVM.VMName)" 63 | write-Host "Checking ${descriptiveName}..." -ForegroundColor Yellow 64 | 65 | # Check the disks 66 | $disksAreReadyOnly = $true 67 | $tempVM.HardDrives | % { 68 | $disk = $_ 69 | 70 | If (-Not (Test-Path -Path $disk.Path)) { 71 | $disksAreReadyOnly = $false 72 | Write-Host "Missing disk file $($disk.Path)" -ForegroundColor Red 73 | } else { 74 | if (-Not (Get-Item $disk.Path).IsReadOnly) { 75 | $disksAreReadyOnly = $false 76 | Write-Host "Disk file $($disk.Path) is not ReadOnly" -ForegroundColor Red 77 | } 78 | } 79 | 80 | } 81 | if (-not $disksAreReadyOnly) { return } 82 | 83 | # Import the VM 84 | Write-Host "Importing the VM" -ForegroundColor Cyan 85 | 86 | Import-VM -Path $VMConfig.FullName -Confirm:$false -ErrorAction Continue 87 | } 88 | 89 | Get-ChildItem -Path $rootPath -File | 90 | ? { $_.Extension.ToUpper() -eq '.VMCX'} | 91 | % { 92 | 93 | if ($currentVMs -contains $_.BaseName.ToLower()) { 94 | Write-Host "${_} is already imported. Ignoring" -ForegroundColor Green 95 | } else { 96 | Import-Master $_ 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /HyperV/PurgeVMS.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' 2 | 3 | # Removes VM files that do not exist in the HyperV host 4 | $rootPath = 'C:\HyperV\VMs\Virtual Machines\' 5 | 6 | $currentVMs = (Get-VM | % { Write-Output $_.Id.ToString().ToLower() }) 7 | if ($null -eq $currentVMs) { $currentVMs = @() } 8 | if ($currentVMs.GetType().ToString() -ne 'System.Object[]') { $currentVMs = @($currentVMs) } 9 | 10 | Function Remove-VMFiles($VMConfig) { 11 | $basename = $VMConfig.BaseName 12 | 13 | Get-ChildItem -Path $rootPath -Filter "$basename.*" -File | ForEach-Object { 14 | Write-Host "Removing $($_.FullName)" -ForegroundColor Yellow 15 | Remove-Item $_.FullName -Confirm:$false -Force | Out-Null 16 | } 17 | 18 | $VMPath = Join-Path $rootPath $basename 19 | if (Test-Path -Path $VMPath) { 20 | Write-Host "Removing $VMPath" -ForegroundColor Yellow 21 | Remove-Item $VMPath -Recurse -Confirm:$false -Force | Out-Null 22 | } 23 | } 24 | 25 | Get-ChildItem -Path $rootPath -File | 26 | ? { $_.Extension.ToUpper() -eq '.VMCX'} | 27 | % { 28 | 29 | if ($currentVMs -contains $_.BaseName.ToLower()) { 30 | Write-Host "${_} is already imported. Ignoring" -ForegroundColor Green 31 | } else { 32 | Remove-VMFiles $_ 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /HyperV/SetupHyperVNetworking.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | $ExternalAdapterName = $null 3 | ) 4 | $ErrorActionPreference = 'Stop' 5 | 6 | $ThisHost = Get-VMHost | Select-Object -First 1 7 | 8 | $VHDPath = 'C:\HyperV\Disks' 9 | if ($ThisHost.VirtualHardDiskPath -ne $VHDPath) { 10 | $ThisHost | Set-VMHost -VirtualHardDiskPath $VHDPath 11 | } else { Write-Host "VM Disk Path is correct" -ForegroundColor Green } 12 | 13 | $VMPath = 'C:\HyperV\VMs' 14 | if ($ThisHost.VirtualMachinePath -ne $VMPath) { 15 | $ThisHost | Set-VMHost -VirtualMachinePath $VMPath 16 | } else { Write-Host "VM Path is correct" -ForegroundColor Green } 17 | 18 | # Setup an External VSwitch 19 | $ExternalSwitch = Get-VMSwitch | ? { $_.Name -eq 'External' } 20 | if ($null -eq $ExternalSwitch) { 21 | if ($null -eq $ExternalAdapterName) { 22 | Write-Host "Available network adapters:" 23 | Get-NetAdapter | Format-Table 24 | Throw "ExternalAdapterName is required" 25 | return; 26 | } 27 | Write-Host "Creating External VSwitch ($ExternalAdapterName)..." 28 | New-VMSwitch -Name 'External' -AllowManagementOS $True -NetAdapterName $ExternalAdapterName 29 | } else { 30 | Write-Host "External VSwitch Exists" -ForegroundColor Green 31 | } 32 | 33 | $InternalVNicName = 'Internal (with NAT)' 34 | 35 | $InternalNATSwitch = Get-VMSwitch | ? { $_.Name -eq $InternalVNicName } 36 | if ($null -eq $InternalNATSwitch) { 37 | Write-Host "Creating Internal NAT vSwitch..." 38 | New-VMSwitch -Name $InternalVNicName -SwitchType Internal 39 | # Need a delay to allow the VNic to be created. 40 | Start-Sleep -Seconds 2 41 | } else { 42 | Write-Host "Internal NAT VSwitch Exists" -ForegroundColor Green 43 | } 44 | 45 | $InternalNIC = Get-NetAdapter -Name "vEthernet ($($InternalVNicName))" 46 | if ($null -eq $InternalNIC) { 47 | Throw "Internal NAT Nic is missing!!" 48 | return; 49 | } 50 | 51 | $ip = Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias "vEthernet ($($InternalVNicName))" 52 | if ($ip.ToString() -ne '192.168.200.1' ) { 53 | New-NetIPAddress -InterfaceAlias "vEthernet ($($InternalVNicName))" -IPAddress '192.168.200.1' -AddressFamily IPv4 54 | } else { Write-Host "Internal NAT Interface is configured" -ForegroundColor Green } 55 | 56 | # Reset NAT 57 | $nat = Get-NetNat | Select -First 1 58 | if (($null -eq $nat) -or ($nat.Name -ne 'Internal HyperV NAT')) { 59 | Get-NetNat | Remove-Netnat -Confirm:$false | Out-Null 60 | New-NetNat -Name 'Internal HyperV NAT' -InternalIPInterfaceAddressPrefix '192.168.200.0/24' 61 | } else { Write-Host "Internal NAT is configured" -ForegroundColor Green } 62 | 63 | # Setup DHCP 64 | if (!(Test-Path -Path HKLM:\SYSTEM\CurrentControlSet\services\DHCPServerHelper)) { 65 | # Install service 66 | & 'C:\HyperV\Helpers\dhcpd\dhcpsrv.exe' -install 67 | # Rename service name due to a conflict. 68 | Rename-Item HKLM:\SYSTEM\CurrentControlSet\services\DHCPServer DHCPServerHelper 69 | Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\services\DHCPServerHelper -Name 'DisplayName' -Value 'DHCP Server (Helper)' 70 | # Add Firewall config 71 | & 'C:\HyperV\Helpers\dhcpd\dhcpsrv.exe' -configfirewall 72 | } else { Write-Host "DHCP Server is configured" -ForegroundColor Green } 73 | -------------------------------------------------------------------------------- /ImportMasterVMs.ps1: -------------------------------------------------------------------------------- 1 | $rootPath = 'C:\HyperV\VMs\Virtual Machines\' 2 | 3 | $currentVMs = (Get-VM | % { Write-Output $_.Id.ToString().ToLower() }) 4 | if ($currentVMs.GetType().ToString() -ne 'System.Object[]') { $currentVMs = @($currentVMs) } 5 | 6 | Function Import-Master($VMConfig) { 7 | try { 8 | $tempVM = (Compare-VM -Copy -Path $VMConfig.FullName -GenerateNewID -ErrorAction Stop).VM 9 | } catch { 10 | Write-Host "Unable to query ${VMconfig.FullName}" -ForegroundColor Red 11 | return 12 | } 13 | 14 | $descriptiveName = "(${VMConfig}) $($tempVM.VMName)" 15 | write-Host "Checking ${descriptiveName}..." -ForegroundColor Yellow 16 | 17 | # Check the disks 18 | $disksAreReadyOnly = $true 19 | $tempVM.HardDrives | % { 20 | $disk = $_ 21 | 22 | If (-Not (Test-Path -Path $disk.Path)) { 23 | $disksAreReadyOnly = $false 24 | Write-Host "Missing disk file $($disk.Path)" -ForegroundColor Red 25 | } else { 26 | if (-Not (Get-Item $disk.Path).IsReadOnly) { 27 | $disksAreReadyOnly = $false 28 | Write-Host "Disk file $($disk.Path) is not ReadOnly" -ForegroundColor Red 29 | } 30 | } 31 | 32 | } 33 | if (-not $disksAreReadyOnly) { return } 34 | 35 | # Import the VM 36 | Write-Host "Importing the VM" -ForegroundColor Cyan 37 | Import-VM -Path $VMConfig.FullName -Confirm:$false 38 | } 39 | 40 | Get-ChildItem -Path $rootPath -File | 41 | ? { $_.Extension.ToUpper() -eq '.VMCX'} | 42 | % { 43 | 44 | if ($currentVMs -contains $_.BaseName.ToLower()) { 45 | Write-Host "${_} is already imported. Ignoring" -ForegroundColor Green 46 | } else { 47 | Import-Master $_ 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Glenn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LocalRM.ps1: -------------------------------------------------------------------------------- 1 | Param($VMName = '') 2 | $ErrorActionPreference = 'Stop' 3 | 4 | $vmList = Get-VM | ? { $_.State -eq 'Running' } | % { Write-Output $_.Name } | Sort-Object 5 | if ($vmList -eq $null) { Write-Host 'No running VMs'; return } 6 | if ($vmList.GetType().ToString() -eq 'System.String') { $vmList = @($vmList) } 7 | 8 | # Get the VM Name 9 | $vmName = '' 10 | do { 11 | $index = 1 12 | Write-Host "Running VMs" 13 | $vmList | % { 14 | Write-Host "$($index). $($_)" 15 | $index++ 16 | } 17 | $misc = Read-Host -Prompt "Select a VM (1..$($vmList.Length))" 18 | try { 19 | $vmName = $vmList[$misc - 1] 20 | } catch { $vmName = '' } 21 | } while ($vmName -eq '') 22 | 23 | $ips = Get-VM -Name $VMName | ?{$_.ReplicationMode -ne "Replica"} | Select -ExpandProperty NetworkAdapters | Select IPAddresses 24 | if ($ips -eq $null) { Write-Host "$VMName has no IP Addresses"; return } 25 | $itsIP = $ips.IPAddresses | ? { $_ -like '192.168.200.*' } 26 | if ($itsIP -eq $null) { Write-Host "$VMName has no 192.168.200.x address"; return } 27 | 28 | Enter-PSSession -ComputerName $itsIP -Credential (Get-Credential 'Administrator') 29 | -------------------------------------------------------------------------------- /Public-Network-Detector.txt: -------------------------------------------------------------------------------- 1 | Get-NetConnectionProfile | ? { $_.NetworkCategory -eq 'Public' } | Set-NetConnectionProfile -NetworkCategory Private -------------------------------------------------------------------------------- /RemoveVM.ps1: -------------------------------------------------------------------------------- 1 | Param($VMName = '') 2 | $ErrorActionPreference = 'Stop' 3 | 4 | $vmList = @{} 5 | Get-VM | % { 6 | $thisVM = $_ 7 | 8 | $hasDiffDisk = $false 9 | $thisVM | Get-VMHardDiskDrive | Get-VHD | ? { $_.VhdType -eq 'Differencing' } | % { 10 | $hasDiffDisk = $true 11 | } 12 | 13 | if ($hasDiffDisk) { $vmList.Add($thisVM.Name,$thisVM) } 14 | } 15 | 16 | 17 | # Get Template Name if not supplied 18 | while (-not ($vmList.ContainsKey($VMName))) { 19 | Write-Host "Remove VM" 20 | $vmList.GetEnumerator() | % { 21 | Write-Host "- $($_.Key)" 22 | } 23 | $VMName = Read-Host -Prompt "Enter VM Name" 24 | } 25 | 26 | 27 | $diskList = ($vmList.Item($VMName) | Get-VMHardDiskDrive | Get-VHD | % { Write-Output $_.Path }) 28 | 29 | Write-Host "Removing VM..." 30 | $vmList.Item($VMName) | Stop-VM -Confirm:$false -Force -TurnOff -Save:$false -ErrorAction 'SilentlyContinue' 31 | $vmList.Item($VMName) | Remove-VM -Confirm:$false -Force | Out-Null 32 | Write-Host "Removing Disks..." 33 | $diskList | % { 34 | If (Test-Path -Path $_) { 35 | $_ | Remove-Item -Force -Confirm:$false | Out-Null 36 | } else { 37 | Write-Host "Disk at $($_) is already removed " 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /RubyCerts.ps1: -------------------------------------------------------------------------------- 1 | $CACertFile = Join-Path -Path $ENV:AppData -ChildPath 'RubyCACert.pem' 2 | 3 | If (-Not (Test-Path -Path $CACertFile)) { 4 | Write-Output "Downloading CA Cert bundle..." 5 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 6 | Invoke-WebRequest -Uri 'https://curl.haxx.se/ca/cacert.pem' -UseBasicParsing -OutFile $CACertFile | Out-Null 7 | } 8 | 9 | Write-Output "CA Certificate store set to ${CACertFile}" 10 | $ENV:SSL_CERT_FILE = $CACertFile 11 | -------------------------------------------------------------------------------- /Start-Portainer.ps1: -------------------------------------------------------------------------------- 1 | param([Switch]$Force) 2 | $ErrorActionPreference = 'Stop' 3 | 4 | $RootDir = Join-path -Path $PSScriptRoot -ChildPath 'portainer_data' 5 | If (-not(Test-Path -Path $RootDir)) { New-Item -ItemType Directory -Path $RootDir | Out-Null } 6 | 7 | $PortainerDir = Join-Path -Path $RootDir -ChildPath 'portainer' 8 | $DataDir = Join-Path -Path $RootDir -ChildPath 'data' 9 | If (-not(Test-Path -Path $DataDir)) { New-Item -ItemType Directory -Path $DataDir | Out-Null } 10 | $FlagFile = Join-Path -Path $RootDir -ChildPath "check.flag" 11 | 12 | Function Update-Portainer { 13 | [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 14 | Write-Host "Checking if Portainer is latest..." 15 | $result = Invoke-RestMethod -Uri 'https://api.github.com/repos/portainer/portainer/releases/latest' -UseBasicParsing -Method Get 16 | 17 | $asset = $result.assets | Where-Object { $_.name -match 'windows\-amd64\.tar\.gz'} | Select-Object -First 1 18 | $asset_filename = Join-Path -Path $RootDir -ChildPath $asset.name 19 | 20 | if (!(Test-Path -Path $asset_filename)) { 21 | Write-Host "Downloading Portainer..." 22 | Invoke-WebRequest -Uri $asset.browser_download_url -UseBasicParsing -OutFile $asset_filename 23 | } else { 24 | Write-Host "Portainer is up to date." 25 | return 26 | } 27 | 28 | If (Test-Path -Path $PortainerDir) { 29 | Write-Host "Clearing out old portainer installation..." 30 | Remove-Item $PortainerDir -Force -Recurse -Confirm:$false | Out-Null 31 | } 32 | 33 | # Cleanup prior 34 | Get-ChildItem -Path "$RootDir\*.tar" | Remove-Item -Confirm:$false -Force | Out-Null 35 | 36 | Write-Host "Extracting gzip..." 37 | & 7z x $asset_filename -o"`"$RootDir`"" 38 | 39 | Write-Host "Extracting tarball..." 40 | $asset_filename_tar = $asset_filename -replace ".gz$","" 41 | Write-Host $asset_filename_tar 42 | # We HOPE that portainer extracts to the child portainer directory... 43 | & 7z x $asset_filename_tar -o"`"$RootDir`"" 44 | 45 | # Cleanup post 46 | Get-ChildItem -Path "$RootDir\*.tar" | Remove-Item -Confirm:$false -Force | Out-Null 47 | 48 | # Flag last update 49 | Get-Date | Out-File -FilePath $FlagFile 50 | } 51 | 52 | $DoUpdate = $false 53 | if (Test-Path -Path $PortainerDir) { 54 | 55 | $fileCheck = Get-ChildItem -path $FlagFile -ErrorAction SilentlyContinue 56 | if ($null -eq $fileCheck) { 57 | Get-Date | Out-File -FilePath $FlagFile 58 | } else { 59 | $flagAge = New-TimeSpan -Start $fileCheck.LastWriteTime -End (Get-Date) 60 | $DoUpdate = ($flagAge.TotalDays -ge 14) # Check every two weeks 61 | } 62 | } else { 63 | $DoUpdate = $true 64 | } 65 | 66 | if ($DoUpdate -or $Force) { Update-Portainer } 67 | 68 | Write-Host 'Starting Portainer...' 69 | Start-Process -FilePath (Join-Path -Path $PortainerDir -ChildPath 'portainer.exe') -WorkingDirectory $PortainerDir -ArgumentList @( ` 70 | "--data=`"$DataDir`"", ` 71 | "--template-file=`"$PortainerDir\templates.json`"", ` 72 | "--host=tcp://127.0.0.1:2375"` 73 | ) -Wait:$false -NoNewWindow:$false | Out-Null 74 | 75 | Start-Process 'http://localhost:9000' 76 | -------------------------------------------------------------------------------- /archive/Install-cpp-build.ps1: -------------------------------------------------------------------------------- 1 | # From Facter Appveyor file 2 | # https://github.com/puppetlabs/facter/blob/master/appveyor.yml 3 | # This script requires Powershell 3.0 4 | 5 | $ErrorActionPreference = 'Stop' 6 | $VerbosePreference = 'Continue' 7 | 8 | # Sanity Checks 9 | Write-Verbose 'Sanity checks...' 10 | # 64bit OS 11 | if ([IntPtr]::Size -ne 8) { Throw 'This is not a 64bit Operating System'; return } 12 | # Choco 13 | $chocoExe = Get-Command 'choco' -ErrorAction SilentlyContinue 14 | if ($chocoExe -eq $null) { 15 | Write-Host "Chocolatey is not installed or can not be located. If you've installed Chocolatey recently" 16 | Write-Host "please close this window and start a new session first." 17 | Write-Host "" 18 | $misc = Read-Host -Prompt "Would you like to install Chocolatey? (Y/N)" 19 | if (($misc -eq 'Y') -or ($misc -eq 'y')) { 20 | Write-Host 'Starting the installation' 21 | iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex 22 | Write-Host "-------------------------------" 23 | Write-Host "You will need to shut down and restart powershell and/or consoles first prior to using choco." 24 | return; 25 | } else { 26 | Throw 'Chocolatey is not installed'; return 27 | } 28 | } 29 | # Ruby 30 | $rubyExe = Get-Command 'ruby' -ErrorAction SilentlyContinue 31 | if ($rubyExe -eq $null) { 32 | Write-Host "Ruby is not installed or can not be located. If you've installed Ruby recently" 33 | Write-Host "please close this window and start a new session first." 34 | Write-Host "" 35 | $misc = Read-Host -Prompt "Would you like to install Ruby? (Y/N)" 36 | if (($misc -eq 'Y') -or ($misc -eq 'y')) { 37 | Write-Host 'Starting the installation' 38 | & choco install ruby -y 39 | Write-Host "-------------------------------" 40 | Write-Host "You will need to shut down and restart powershell and/or consoles first prior to using ruby." 41 | return; 42 | } else { 43 | Throw 'Ruby is not on the PATH'; return 44 | } 45 | } 46 | # Admin rights 47 | if (-not [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) { throw "This command is not running with administrative rights."; return; } 48 | 49 | # Get default values: 50 | $INSTALL_LOCATION = 'C:\buildtools' 51 | # Query github for latest versions of Leatherman and CPP HOCON 52 | $response = Invoke-RestMethod -URI 'https://api.github.com/repos/puppetlabs/leatherman/releases/latest' -Verbose:$false 53 | $LEATHERMAN_VERSION = $response.tag_name # '0.9.1' 54 | $response = Invoke-RestMethod -URI 'https://api.github.com/repos/puppetlabs/cpp-hocon/releases/latest' -Verbose:$false 55 | $CPPHOCON_VERSION = $response.tag_name # '0.1.3' 56 | 57 | # User input time... 58 | Write-Verbose "Prompting for tool information..." 59 | $misc = Read-Host -Prompt "Please enter a Leatherman Version to use [Press enter to use $LEATHERMAN_VERSION])" 60 | if ($misc -ne '') { $LEATHERMAN_VERSION = $misc} 61 | $misc = Read-Host -Prompt "Please enter a CPP HOCON Version to use [Press enter to use $CPPHOCON_VERSION])" 62 | if ($misc -ne '') { $CPPHOCON_VERSION = $misc} 63 | $misc = Read-Host -Prompt "Please enter a location to store build tools [Press enter to use $INSTALL_LOCATION])" 64 | if ($misc -ne '') { $INSTALL_LOCATION = $misc} 65 | 66 | if (-not (Test-Path -Path $INSTALL_LOCATION)) { New-Item -Path $INSTALL_LOCATION -ItemType 'Directory' -Force -Confirm:$false | Out-Null} 67 | 68 | Write-Verbose "Installing chocolatey packages..." 69 | & choco install mingw-w64 -y --version '4.8.3' -source https://www.myget.org/F/puppetlabs 70 | & choco install cmake -y --version '3.2.2' -source https://www.myget.org/F/puppetlabs 71 | & choco install -y gettext --version '0.19.6' -source https://www.myget.org/F/puppetlabs 72 | & choco install 7zip.commandline -y 73 | 74 | # Modify the PATH 75 | Write-Verbose "Modifying the PATH..." 76 | if (-not ($ENV:Path -like '*C:\Program Files\gettext-iconv*')) { 77 | Write-Verbose "Adding gettext-iconv to the path..." 78 | $ENV:PATH = 'C:\Program Files\gettext-iconv;' + $ENV:PATH 79 | } 80 | # MingW _MUST_ be at the beginning of the path 81 | if (-not ($ENV:Path -like 'C:\tools\mingw64\bin*')) { 82 | Write-Verbose "Adding mingw64 to the path..." 83 | $ENV:PATH = 'C:\tools\mingw64\bin;' + $ENV:PATH 84 | } 85 | $ENV:PATH = $ENV:PATH.Replace("Git\bin", "Git\cmd") 86 | $ENV:PATH = $ENV:PATH.Replace("Git\usr\bin", "Git\cmd") 87 | 88 | # Modify SYSTEM PATH if needed 89 | $misc = Read-Host -Prompt "Should the PATH environment variable for the computer be modified too? (Y/N)" 90 | if (($misc -eq 'Y') -or ($misc -eq 'y')) { 91 | Write-Warning "**** THIS MAY REQUIRE A LOGOFF OR REBOOT TO TAKE AFFECT ****" 92 | $Hive = [Microsoft.Win32.Registry]::LocalMachine 93 | $Key = $Hive.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\Environment",$true) 94 | 95 | $CurrentPATH = $Key.GetValue("path",$False, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames) 96 | if (-not ($CurrentPATH -like '*C:\Program Files\gettext-iconv*')) { 97 | $CurrentPATH = 'C:\Program Files\gettext-iconv;' + $CurrentPATH 98 | } 99 | # MingW _MUST_ be at the beginning of the path 100 | if (-not ($CurrentPATH -like 'C:\tools\mingw64\bin*')) { 101 | $CurrentPATH = 'C:\tools\mingw64\bin;' + $CurrentPATH 102 | } 103 | 104 | $Key.SetValue('Path',$CurrentPATH,'ExpandString') 105 | } 106 | 107 | # Temp file for downloads 108 | $tempFile = Join-Path -Path $ENV:Temp -ChildPath 'cpp-temp-download.7z' 109 | 110 | # Get boost 111 | $boostDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "boost_*" 112 | if ($boostDir -eq $null) { 113 | Write-Verbose "Grabbing boost 4.8.3 ..." 114 | If (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Force -Confirm:$false | Out-Null } 115 | (New-Object System.Net.WebClient).DownloadFile( 116 | 'https://s3.amazonaws.com/kylo-pl-bucket/boost_1_57_0-x86_64_mingw-w64_4.8.3_win32_seh.7z', $tempFile) 117 | 118 | & 7z.exe x $tempFile "-o$($INSTALL_LOCATION)" 119 | 120 | $boostDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "boost_*" 121 | } 122 | Write-Verbose "Boost installed at $($boostDir.FullName)" 123 | 124 | # Get yaml-cpp 125 | $yamlcppDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "yaml-cpp-*" 126 | if ($yamlcppDir -eq $null) { 127 | Write-Verbose "Grabbing yaml-app 0.5.1 ..." 128 | If (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Force -Confirm:$false | Out-Null } 129 | (New-Object System.Net.WebClient).DownloadFile( 130 | 'https://s3.amazonaws.com/kylo-pl-bucket/yaml-cpp-0.5.1-x86_64_mingw-w64_4.8.3_win32_seh.7z', $tempFile) 131 | 132 | & 7z.exe x $tempFile "-o$($INSTALL_LOCATION)" 133 | 134 | $yamlcppDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "yaml-cpp-*" 135 | } 136 | Write-Verbose "YAML CPP installed at $($yamlcppDir.FullName)" 137 | 138 | # Get curl 139 | $curlDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "curl-*" 140 | if ($curlDir -eq $null) { 141 | Write-Verbose "Grabbing curl 7.42.1 ..." 142 | If (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Force -Confirm:$false | Out-Null } 143 | (New-Object System.Net.WebClient).DownloadFile( 144 | 'https://s3.amazonaws.com/kylo-pl-bucket/curl-7.42.1-x86_64_mingw-w64_4.8.3_win32_seh.7z', $tempFile) 145 | 146 | & 7z.exe x $tempFile "-o$($INSTALL_LOCATION)" 147 | 148 | $curlDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "curl-*" 149 | } 150 | Write-Verbose "Curl installed at $($curlDir.FullName)" 151 | 152 | # Get leatherman 153 | $leathermanDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "leatherman*" 154 | if ($leathermanDir -eq $null) { 155 | Write-Verbose "Grabbing leatherman $LEATHERMAN_VERSION ..." 156 | If (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Force -Confirm:$false | Out-Null } 157 | (New-Object System.Net.WebClient).DownloadFile( 158 | "https://github.com/puppetlabs/leatherman/releases/download/$LEATHERMAN_VERSION/leatherman.7z", $tempFile) 159 | 160 | & 7z.exe x $tempFile "-o$($INSTALL_LOCATION)" 161 | 162 | $leathermanDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "leatherman*" 163 | } 164 | Write-Verbose "Leatherman installed at $($leathermanDir.FullName)" 165 | 166 | # Get cpphocon 167 | $hoconDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "cpp-hocon*" 168 | if ($hoconDir -eq $null) { 169 | Write-Verbose "Grabbing CPP HOCON $CPPHOCON_VERSION ..." 170 | If (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Force -Confirm:$false | Out-Null } 171 | (New-Object System.Net.WebClient).DownloadFile( 172 | "https://github.com/puppetlabs/cpp-hocon/releases/download/$CPPHOCON_VERSION/cpp-hocon.7z", $tempFile) 173 | 174 | & 7z.exe x $tempFile "-o$($INSTALL_LOCATION)" 175 | 176 | $hoconDir = Get-ChildItem -Path $INSTALL_LOCATION -Filter "cpp-hocon*" 177 | } 178 | Write-Verbose "CPP HOCON installed at $($hoconDir.FullName)" 179 | 180 | 181 | # Create helper batch and powershell scripts. These are run from within a facter repos 182 | # The helpers typically just setup the environment path first and then do 'something' 183 | 184 | Write-Verbose "Create build batch files..." 185 | @" 186 | @ECHO OFF 187 | 188 | SET PATH=$($ENV:PATH) 189 | 190 | SET FACTER_SRC=. 191 | if NOT [%1]==[] SET FACTER_SRC=%1 192 | 193 | cmake -G `"MinGW Makefiles`" -DBOOST_ROOT=`"$($boostDir.FullName)`" -DYAMLCPP_ROOT=`"$($yamlcppDir.FullName)`" -DBOOST_STATIC=ON -DCURL_STATIC=ON -DCMAKE_INSTALL_PREFIX=`"C:\Program Files\FACTER`" -DCMAKE_PREFIX_PATH=`"$($leathermanDir.FullName);$($curlDir.FullName);$($hoconDir.FullName)`" %FACTER_SRC% 194 | mingw32-make clean install -j2 195 | 196 | "@ | Out-File -FilePath "$INSTALL_LOCATION\build-facter.bat" -Encoding 'ASCII' 197 | 198 | @" 199 | @ECHO OFF 200 | 201 | SET PATH=$($ENV:PATH) 202 | 203 | ECHO Ready for work 204 | "@ | Out-File -FilePath "$INSTALL_LOCATION\build-env.bat" -Encoding 'ASCII' 205 | 206 | Write-Verbose "Create test ps1 files..." 207 | @" 208 | `$ENV:PATH = `"$($ENV:PATH)`" 209 | 210 | ctest -V 2>&1 | %{ if (`$_ -is [System.Management.Automation.ErrorRecord]) { `$_ | c++filt } else { `$_ } } 211 | mingw32-make install 212 | 213 | "@ | Out-File -FilePath "$INSTALL_LOCATION\test-facter.ps1" -Encoding 'ASCII' 214 | 215 | @" 216 | ----------------------------------------------------------------------- 217 | From within a puppetlabs-facter repository you can call: 218 | 219 | $($INSTALL_LOCATION)\build-env.bat Sets environment vars for building facter 220 | 221 | $($INSTALL_LOCATION)\build-facter.bat Builds facter from the root of a facter repo 222 | $($INSTALL_LOCATION)\build-facter.bat Builds facter with a path to the facter source e.g. in 'facter/release' would call '$($INSTALL_LOCATION)\build-facter.bat ..' 223 | 224 | $($INSTALL_LOCATION)\test-facter.bat Runs tests from the root of a facter repo 225 | 226 | ----------------------------------------------------------------------- 227 | "@ | Write-Host -ForegroundColor Green 228 | -------------------------------------------------------------------------------- /archive/InstallDockerEE.ps1: -------------------------------------------------------------------------------- 1 | # Assumes Docker Desktop for Windows is already installed 2 | 3 | # On an online machine, download the zip file. 4 | $OutFile = Join-Path $ENV:TEMP 'docker-19.03.5.zip' 5 | Invoke-WebRequest -UseBasicParsing -OutFile $OutFile https://download.docker.com/components/engine/windows-server/19.03/docker-19.03.5.zip 6 | 7 | # Extract the archive. 8 | Expand-Archive $OutFile -DestinationPath $Env:ProgramFiles -Force 9 | 10 | Start-Process -FilePath "$($Env:ProgramFiles)\docker\dockerd.exe" -ArgumentList @('--debug') -NoNewWindow:$false -Wait:$false 11 | 12 | & docker pull mcr.microsoft.com/windows:1909 13 | -------------------------------------------------------------------------------- /archive/PuppetDevEnv/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/windowsservercore 2 | 3 | MAINTAINER glennsarti 4 | 5 | LABEL Description="Puppet Dev Environment" Version="1.0.0" 6 | 7 | #ENTRYPOINT ["powershell.exe","C:/neo4j/docker-entrypoint.ps1"] 8 | #CMD ["neo4j"] 9 | 10 | COPY tools C:/tools 11 | 12 | RUN powershell C:/tools/docker_file-build.ps1 13 | -------------------------------------------------------------------------------- /archive/PuppetDevEnv/build-context.ps1: -------------------------------------------------------------------------------- 1 | param($BaseImage = 'microsoft/windowsservercore', $include32bit = $false) 2 | $ErrorActionPreference = 'Stop' 3 | 4 | $TempDir = Join-Path -Path $PSScriptRoot -ChildPath 'tmp' 5 | $contextDir = Join-Path -Path $PSScriptRoot -ChildPath 'context' 6 | $rootArtifactDir = Join-Path -Path $contextDir -ChildPath 'tools' 7 | 8 | if (-not (Test-Path -Path $TempDir)) { New-Item -Path $TempDir -ItemType Directory | Out-Null } 9 | if (-not (Test-Path -Path $contextDir)) { New-Item -Path $contextDir -ItemType Directory | Out-Null } 10 | if (-not (Test-Path -Path $rootArtifactDir)) { New-Item -Path $rootArtifactDir -ItemType Directory | Out-Null } 11 | 12 | # Download Manifest 13 | $DownloadManifest = @{ 14 | 'RubyDevkit2_x64' = @{ 15 | 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe'; 16 | 'Filename' = 'devkit.exe'; 17 | 'ArtifactDir' = 'devkit2_x64' 18 | 'DLType' = 'DevKit'; 19 | } 20 | # 'RubyDevkit2_x86' = @{ 21 | # 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe'; 22 | # 'Filename' = 'devkit.exe'; 23 | # 'ArtifactDir' = 'devkit2' 24 | # 'DLType' = 'DevKit'; 25 | # } 26 | 'Ruby231_x64' = @{ 27 | 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.1-x64-mingw32.7z'; 28 | 'Filename' = 'ruby.7z'; 29 | 'ArtifactDir' = 'ruby2_3_1-x64' 30 | 'DLType' = 'Ruby'; 31 | } 32 | # 'Ruby231_i386' = @{ 33 | # 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.1-i386-mingw32.7z'; 34 | # 'Filename' = 'ruby.7z'; 35 | # 'ArtifactDir' = 'ruby2_3_1' 36 | # 'DLType' = 'Ruby'; 37 | # } 38 | 'Ruby218_x64' = @{ 39 | 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.1.8-x64-mingw32.7z'; 40 | 'Filename' = 'ruby.7z'; 41 | 'ArtifactDir' = 'ruby2_1_8-x64' 42 | 'DLType' = 'Ruby'; 43 | } 44 | # 'Ruby218_i386' = @{ 45 | # 'URL' = 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.1.8-i386-mingw32.7z'; 46 | # 'Filename' = 'ruby.7z'; 47 | # 'ArtifactDir' = 'ruby2_1_8' 48 | # 'DLType' = 'Ruby'; 49 | # } 50 | 'URU' = @{ 51 | 'URL' = 'https://bitbucket.org/jonforums/uru/downloads/uru-0.8.2-windows-x86.7z' 52 | 'Filename' = 'uru.7z'; 53 | 'ArtifactDir' = 'uru' 54 | 'DLType' = 'Uru'; 55 | } 56 | } 57 | 58 | # Download temp files 59 | $DownloadManifest.GetEnumerator() | % { 60 | $itemDirectory = Join-Path -Path $TempDir -ChildPath ($_.Key) 61 | $thisItem = $_.Value 62 | $artifactDir = Join-Path -Path $rootArtifactDir -ChildPath $($thisItem.ArtifactDir) 63 | 64 | Write-Host "Checking $($_.Key) ..." 65 | 66 | if (-not (Test-Path -Path $itemDirectory)) { New-Item -Path $itemDirectory -ItemType Directory | Out-Null } 67 | 68 | # Download the artifact 69 | $tempItem = Join-Path -Path $itemDirectory -ChildPath $($thisItem.Filename) 70 | if (-not (Test-Path -Path $tempItem)) { 71 | Write-Host "Downloading $($thisItem.URL) to $($tempItem) ..." 72 | (New-Object System.Net.WebClient).DownloadFile($thisItem.URL, $tempItem) 73 | } 74 | 75 | # Extract it 76 | If (-not (Test-Path -Path $artifactDir)) { 77 | switch ($thisItem.DLType) { 78 | "DevKit" { 79 | Write-Host "Extracting DevKit ..." 80 | & 7z x $tempItem "`"-o$artifactDir`"" -y 81 | } 82 | "Uru" { 83 | Write-Host "Extracting Uru 7zip ..." 84 | & 7z x $tempItem "`"-o$artifactDir`"" -y 85 | 86 | $bat = @" 87 | @echo off 88 | rem autogenerated by uru 89 | 90 | set URU_INVOKER=batch 91 | 92 | "C:\tools\uru\uru_rt.exe" %* 93 | 94 | if "x%URU_HOME%x"=="xx" ( 95 | if exist "%USERPROFILE%\.uru\uru_lackee.bat" (call "%USERPROFILE%\.uru\uru_lackee.bat") 96 | ) else ( 97 | if exist "%URU_HOME%\uru_lackee.bat" (call "%URU_HOME%\uru_lackee.bat") 98 | ) 99 | "@ 100 | 101 | $ps = @" 102 | # autogenerated by uru 103 | 104 | `$env:URU_INVOKER = 'powershell' 105 | 106 | C:\tools\uru\uru_rt.exe `$args 107 | 108 | if (`$env:URU_HOME) { 109 | if(Test-Path "`$env:URU_HOME\uru_lackee.ps1"){ & `$env:URU_HOME\uru_lackee.ps1 } 110 | } else { 111 | if(Test-Path "`$env:USERPROFILE\.uru\uru_lackee.ps1"){ & `$env:USERPROFILE\.uru\uru_lackee.ps1 } 112 | } 113 | "@ 114 | 115 | @{'uru.bat' = $bat; 'uru.ps1' = $ps}.GetEnumerator() | %{ 116 | $sw = [System.IO.StreamWriter] "$(Join-Path $artifactDir $_.Name)" 117 | $sw.Write($_.Value) 118 | $sw.Close() 119 | $sw.Dispose() 120 | } 121 | } 122 | "Ruby" { 123 | Write-Host "Extracting Ruby..." 124 | 125 | $tempExtract = Join-Path -path $itemDirectory -ChildPath 'rubydl_extracted' 126 | if (Test-Path -Path $tempExtract) { Remove-Item -Path $tempExtract -Recurse -Confirm:$false -Force | Out-Null } 127 | & 7z x $tempItem "`"-o$tempExtract`"" -y 128 | 129 | # Get the root directory from the extract 130 | $misc = (Get-ChildItem -Path $tempExtract | ? { $_.PSIsContainer } | Select -First 1).Fullname 131 | 132 | Write-Host "Moving ruby to $artifactDir ..." 133 | Move-Item -Path $misc -Destination $artifactDir -Force -Confirm:$false | Out-Null 134 | } 135 | } 136 | } 137 | } 138 | 139 | # Now all the files are downloaded, create the context 140 | Write-Host "Creating context..." 141 | Copy-Item -Path "$PSScriptRoot\DockerFile" -Debug "$($contextDir)\Dockerfile" -Force -Confirm:$false | Out-Null 142 | Copy-Item -Path "$PSScriptRoot\docker_file-build.ps1" -Debug "$($contextDir)\tools\docker_file-build.ps1" -Force -Confirm:$false | Out-Null 143 | -------------------------------------------------------------------------------- /archive/PuppetDevEnv/build-docker.ps1: -------------------------------------------------------------------------------- 1 | & docker build context --tag "puppet_dev_env:1.0.0" 2 | 3 | -------------------------------------------------------------------------------- /archive/PuppetDevEnv/docker_file-build.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop' 2 | 3 | $uru = 'C:\tools\uru\uru.ps1' 4 | 5 | function Get-UruTag($rubyDir) { 6 | $rubyDir = $rubyDir.replace('ruby','') 7 | $rubyDir = $rubyDir.replace('_','.') 8 | $bareRubyVersion = ($rubyDir -split '-')[0] 9 | 10 | if ($rubyDir -match 'x64') { 11 | Write-Output "$($bareRubyVersion)-x64" 12 | } else { 13 | Write-Output "$($bareRubyVersion)-x86" 14 | } 15 | } 16 | 17 | Write-Host "Checking the SYSTEM Path..." 18 | $Hive = [Microsoft.Win32.Registry]::LocalMachine 19 | $Key = $Hive.OpenSubKey("SYSTEM\CUrrentControlSet\Control\Session Manager\Environment",$true) 20 | $currentPath = $Key.GetValue("Path",$False, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames) 21 | 22 | if ($currentPath -notlike '*uru*') { 23 | Write-Host "Updating the SYSTEM Path..." 24 | $currentPath += ';C:\tools\uru' 25 | 26 | $Key.SetValue('PATH',$currentPath,[Microsoft.Win32.RegistryValueKind]::ExpandString) 27 | } 28 | 29 | # Configure each ruby 30 | Get-ChildItem -Path 'C:\tools' | ? { $_.PSIsContainer } | ? { $_.Name -like 'ruby*' } | % { 31 | $rubyFolder = $_ 32 | $tagName = Get-UruTag $rubyFolder.Name 33 | 34 | Write-Host "------ Configuring $($rubyFolder.Name) ..." 35 | 36 | Write-Host "Adding $($rubyFolder.Fullname) to uru..." 37 | 38 | # Tag in uru 39 | & $uru admin add "$($rubyFolder.Fullname)\bin" --tag "$($tagName)" 40 | 41 | 42 | & $uru $(Get-UruTag $tagName) 43 | Write-Output "Ruby version..." 44 | & ruby -v 45 | Write-Output "Gem version..." 46 | & gem -v 47 | 48 | # Create temporary gemrc for http 49 | $tempRC = Join-Path -path $ENV:Temp -ChildPath 'gem.rc' 50 | @" 51 | --- 52 | :backtrace: false 53 | :bulk_threshold: 1000 54 | :sources: 55 | - http://rubygems.org 56 | :update_sources: true 57 | :verbose: true 58 | "@ | Set-Content -Encoding Ascii -Path $tempRC -Force -Confirm:$false 59 | 60 | Write-Host "Updating system gems (via HTTP)..." 61 | if ($rubyVersion -match '^1\.') { 62 | & gem update --system --no-rdoc --config-file $tempRC 63 | } else { 64 | & gem update --system --no-rdoc --no-document --config-file $tempRC 65 | } 66 | Remove-Item -Path $tempRC -Force -Confirm:$false | Out-Null 67 | 68 | Write-Output "Installing bundler..." 69 | & gem install bundler --no-ri --no-rdoc --no-document 70 | 71 | # Install DevKit ... 72 | if ($tagName -match 'x64') { 73 | $devkitDir = 'C:\tools\devkit2_x64' 74 | } else { 75 | $devkitDir = 'c:\tools\devkit2' 76 | } 77 | @" 78 | --- 79 | - $( ($rubyFolder.Fullname) -replace '\\','/' ) 80 | "@ | Set-Content -Path "$($devkitDir)\config.yml" 81 | Push-Location $devkitDir 82 | Write-Host "Installing DevKit $devKit for $tagName" 83 | & ruby dk.rb install 84 | Pop-Location 85 | } 86 | -------------------------------------------------------------------------------- /archive/RemoveWatches.ps1: -------------------------------------------------------------------------------- 1 | $script:GithubToken = $ENV:GITHUB_TOKEN 2 | $script:GithubUsername = $ENV:GITHUB_USERNAME 3 | 4 | Function Invoke-GithubAPI { 5 | [CmdletBinding()] 6 | 7 | Param( 8 | [Parameter(Mandatory = $True, ParameterSetName = 'RelativeURI')] 9 | [String]$RelativeUri, 10 | 11 | [Parameter(Mandatory = $True, ParameterSetName = 'AbsoluteURI')] 12 | [String]$AbsoluteUri, 13 | 14 | [Parameter(Mandatory = $False)] 15 | [switch]$Raw, 16 | 17 | [String]$Method = 'GET', 18 | 19 | [Object]$Body = $null 20 | ) 21 | 22 | if ($PsCmdlet.ParameterSetName -eq 'RelativeURI') { 23 | $uri = "https://api.github.com" + $RelativeUri 24 | } 25 | else { 26 | $uri = $AbsoluteUri 27 | } 28 | 29 | $result = "" 30 | 31 | $oldPreference = $ProgressPreference 32 | 33 | $auth = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($script:GithubUsername + ':' + $script:GithubToken)); 34 | 35 | $ProgressPreference = 'SilentlyContinue' 36 | $Headers = @{ 37 | 'Accept' = 'application/vnd.github.inertia-preview+json' # Needed for project API 38 | 'Authorization' = $auth; 39 | } 40 | $splat = @{ 41 | 'Uri' = $uri 42 | 'UseBasicParsing' = $True 43 | 'Headers' = $Headers 44 | 'Method' = $Method 45 | } 46 | if ($null -ne $Body) { $splat['Body'] = ConvertTo-Json $Body -Compress } 47 | try { 48 | $result = Invoke-WebRequest @splat -ErrorAction 'Stop' 49 | } catch { 50 | Write-Verbose "Invoke-WebRequest arguments were $($splat | ConvertTo-JSON -Depth 10)" 51 | Throw $_ 52 | } 53 | $ProgressPreference = $oldPreference 54 | 55 | if ($Raw) { 56 | Write-Output $result 57 | } 58 | else { 59 | Write-Output $result.Content | ConvertFrom-JSON 60 | } 61 | } 62 | 63 | # Function Invoke-GithubAPIWithPaging($RelativeUri) { 64 | # $response = Invoke-GithubAPI -RelativeUri $RelativeUri -Raw 65 | # $result = $response.Content | ConvertFrom-Json 66 | # if (!($result -is [Array])) { $result = @($result) } 67 | # $nextLink = $response.RelationLink.next 68 | # do { 69 | # if ($null -ne $nextLink) { 70 | # $response = Invoke-GithubAPI -AbsoluteUri $nextLink -Raw 71 | # $result = $result + ($response.Content | ConvertFrom-Json) 72 | # $nextLink = $response.RelationLink.next 73 | # } 74 | # } 75 | # while ($null -ne $nextLink) 76 | 77 | # Write-Output $result 78 | # } 79 | 80 | $watchedRepos = Invoke-GithubAPI -RelativeUri '/user/subscriptions' 81 | 82 | $watchedRepos | ? { $_.owner.login -eq 'puppetlabs' } | ? { @('puppet-vscode', 'puppet-editor-services', 'puppet-editor-syntax') -notcontains $_.name } | % { 83 | Write-Host "Deleting subscription $($_.name)" 84 | 85 | Invoke-GithubAPI -RelativeUri "/repos/puppetlabs/$($_.name)/subscription" -Method 'DELETE' 86 | } 87 | -------------------------------------------------------------------------------- /archive/SophosBeGone.ps1: -------------------------------------------------------------------------------- 1 | $ServiceList = Get-Service | Where-Object { $_.DisplayName -like '*Sophos*' } 2 | $ServiceList += Get-Service -Include "hmpalertsvc" 3 | 4 | $ServiceList | ForEach-Object { 5 | $Service = $_ 6 | 7 | if ($Service.Status -eq 'Running') { 8 | Write-Host "Stopping '$($Service.Name)' ..." 9 | Stop-Service $Service -Confirm:$False -Force -NoWait -ErrorAction Continue 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /archive/bi-nobeaker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf .bundle/bash 4 | rm Gemfile.lock 5 | 6 | bundle install --path .bundle/bash --without system_tests "$@" 7 | -------------------------------------------------------------------------------- /archive/config-pe-client-tools.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param( 3 | [Parameter(Mandatory = $false)] 4 | [String]$PuppetMaster = '' 5 | ) 6 | $ErrorActionPreference = 'Stop' 7 | 8 | $userDir = Join-Path -Path $ENV:USERPROFILE -ChildPath '.puppetlabs' 9 | $userClientToolsDir = Join-Path -Path $userDir -ChildPath 'client-tools' 10 | $tokenFile = Join-Path -Path $userDir -ChildPath 'token' 11 | $certsDir = Join-Path -Path $ENV:ALLUSERSPROFILE -ChildPath 'PuppetLabs\puppet\etc\ssl\certs' 12 | 13 | ## DANGER - Major hack 14 | Add-type @" 15 | using System.Net; 16 | using System.Security.Cryptography.X509Certificates; 17 | public class IDontCarePolicy : ICertificatePolicy { 18 | public IDontCarePolicy() {} 19 | public bool CheckValidationResult( 20 | ServicePoint sPoint, X509Certificate cert, 21 | WebRequest wRequest, int certProb) { 22 | return true; 23 | } 24 | } 25 | "@ 26 | 27 | Function Invoke-ShowConfiguration() { 28 | Write-Host "" 29 | Write-Host "Gathering information from the PE Client Tools configuration..." 30 | 31 | if (-not (Test-Path -Path $userDir)) { 32 | Write-Warning "The PuppetLabs user directory is missing. Expected to find '$$userDir'" 33 | } 34 | 35 | if (Test-Path -Path $tokenFile) { 36 | $fileInfo = Get-Item -Path $tokenFile 37 | Write-Host "Token file was last updated $($fileInfo.LastWriteTime)" -Foreground Green 38 | } else { 39 | Write-Warning "A token file from the Puppet RBAC service is expected at '$tokenFile'" 40 | } 41 | 42 | # Check config Files 43 | 'puppet-code.conf','puppetdb.conf','puppet-access.conf','orchestrator.conf' | % { 44 | $filepath = Join-Path -Path $userClientToolsDir -ChildPath $_ 45 | if (Test-Path -Path $filePath) { 46 | Write-Host "PE Client Tools configuration file '$_'" -Foreground Green 47 | Get-Content -Path $filePath 48 | 49 | } else { 50 | Write-Warning "Missing configuration file '$filepath'" 51 | } 52 | } 53 | 54 | } 55 | 56 | Function Invoke-QuickConfig($puppetMaster = '') { 57 | Write-Host "Creating required directories..." 58 | # Quick hack but it works ... 59 | if (-Not (Test-Path -Path $certsDir)) { 60 | (& cmd /c md "`"$certsDir`"") | Out-Null 61 | } 62 | if (-Not (Test-Path -Path $userClientToolsDir)) { 63 | (& cmd /c md "`"$userClientToolsDir`"") | Out-Null 64 | } 65 | 66 | if ($puppetMaster -eq '') { 67 | $puppetMaster = Read-Host "Enter Puppet Master name" 68 | } 69 | 70 | # Sanity Check - Resolve by name 71 | try { 72 | Write-Host "Attempting to resolve $puppetMaster ..." 73 | $result = [System.Net.Dns]::gethostentry($puppetMaster) 74 | Write-Host "$puppetMaster has resolved to IP $($result.AddressList)" 75 | } catch { 76 | Write-Warning "Unable to resolve $puppetMaster by name" 77 | return 78 | } 79 | 80 | # Get the master certificate... 81 | $caCertFile = Join-Path -Path $certsDir -ChildPath 'ca.pem' 82 | if (Test-Path -Path $caCertFile) { 83 | Write-Host "Removing previous CA Master certificate..." 84 | Remove-Item -Path $caCertFile -Force -Confirm:$false | Out-Null 85 | } 86 | 87 | try { 88 | [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy 89 | Write-Host "Fetching the CA Master certificate ..." 90 | $wc = New-Object System.Net.WebClient 91 | $wc.DownloadFile("https://$($puppetMaster):8140/puppet-ca/v1/certificate/ca",$caCertFile) 92 | } catch { 93 | Write-Warning "Error from $PuppetMaster was $_" 94 | return 95 | } 96 | 97 | # [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy 98 | # Write-Host "Fetching the CA Master certificate ..." 99 | # $response = Invoke-WebRequest -URI "https://$($puppetMaster):8140/puppet-ca/v1/certificate/ca" -UseBasicParsing 100 | # if ($response.StatusCode -ne 200) { Write-Warning "Response code $($response.StatusCode) from Puppet Master was not OK."; return } 101 | # $response.Content | Out-File -FilePath $caCertFile -Encoding "ASCII" 102 | 103 | Write-Host "Writing config files with defaults..." 104 | # Write the config files 105 | @" 106 | { 107 | "service-url": "https://$($puppetMaster):4433/rbac-api" 108 | } 109 | "@ | Out-File -FilePath (Join-Path -Path $userClientToolsDir -ChildPath 'puppet-access.conf') -Encoding "ASCII" 110 | 111 | @" 112 | { 113 | "options" : { 114 | "service-url": "https://$($puppetMaster):8143" 115 | } 116 | } 117 | "@ | Out-File -FilePath (Join-Path -Path $userClientToolsDir -ChildPath 'orchestrator.conf') -Encoding "ASCII" 118 | 119 | @" 120 | { 121 | "service-url": "https://$($puppetMaster):8170/code-manager" 122 | } 123 | "@ | Out-File -FilePath (Join-Path -Path $userClientToolsDir -ChildPath 'puppet-code.conf') -Encoding "ASCII" 124 | 125 | @" 126 | { 127 | "puppetdb": { 128 | "server_urls": "https://$($puppetMaster):8081", 129 | "cacert": "$($caCertFile -replace '\\','\\')" 130 | } 131 | } 132 | "@ | Out-File -FilePath (Join-Path -Path $userClientToolsDir -ChildPath 'puppetdb.conf') -Encoding "ASCII" 133 | 134 | Write-Host "Quick configuration completed!" 135 | Invoke-ShowConfiguration 136 | } 137 | 138 | # Main 139 | Write-Host "PE Client Tools Helper" 140 | Write-Host "----------------------" 141 | 142 | $PEClientToolsPath = 'C:\Program Files\Puppet Labs\Client' 143 | $PEClientToolsBinPath = "$($PEClientToolsPath)\bin" 144 | 145 | If (-not (Test-Path -Path $PEClientToolsBinPath)) { 146 | Write-Warning "Could not locate the PE Client Tools at '$($PEClientToolsPath)'" 147 | return 148 | } 149 | 150 | if ($PuppetMaster -eq '') { 151 | $validOptions = @('1','2','3') 152 | 153 | # Show Menu 154 | Write-Host '1. Start the PE Client Tools Shell' 155 | Write-Host '2. Show current PE Client Tool configuration' 156 | Write-Host '3. Quick config PE Client Tools' 157 | Write-Host '' 158 | do { 159 | $option = Read-Host -Prompt "Enter select ($($validOptions -join ','))" 160 | } until ($validOptions -contains $option) 161 | 162 | switch ($option) { 163 | '1' { Start-Process -FilePath "cmd.exe" -Argument @('/k',"`"$($PEClientToolsBinPath)\pe_client_shell.bat`"") | Out-Null } 164 | '2' { Invoke-ShowConfiguration } 165 | '3' { Invoke-QuickConfig } 166 | } 167 | } else { 168 | Write-Host "Running quick config for puppet master $PuppetMaster" 169 | Invoke-QuickConfig -PuppetMaster $PuppetMaster 170 | } 171 | -------------------------------------------------------------------------------- /archive/create-pdk-shell.ps1: -------------------------------------------------------------------------------- 1 | $fso = New-Object -ComObject Scripting.FileSystemObject 2 | 3 | $ENV:DEVKIT_BASEDIR = (Get-ItemProperty -Path "HKLM:\Software\Puppet Labs\DevelopmentKit").RememberedInstallDir64 4 | # Windows API GetShortPathName requires inline C#, so use COM instead 5 | $ENV:DEVKIT_BASEDIR = $fso.GetFolder($ENV:DEVKIT_BASEDIR).ShortPath 6 | $ENV:RUBY_DIR = "$($ENV:DEVKIT_BASEDIR)\private\ruby\2.1.9" 7 | $ENV:SSL_CERT_FILE = "$($ENV:DEVKIT_BASEDIR)\ssl\cert.pem" 8 | $ENV:SSL_CERT_DIR = "$($ENV:DEVKIT_BASEDIR)\ssl\certs" 9 | # $ENV:GEM_HOME = Join-Path $ENV:LOCALAPPDATA 'PDK\cache\ruby\2.1.0' 10 | $ENV:GEM_PATH = Join-Path $ENV:DEVKIT_BASEDIR 'share\cache\ruby\2.1.0' 11 | 12 | #PATH=C:/PROGRA~1/PUPPET~1/DEVELO~1/private/ruby/2.1.9/bin;C:\Users\glenn.sarti\AppData\Local/PDK/cache/ruby/2.1.0/bin;C:/PROGRA~1/PUPPET~1/DevelopmentKit/share/cache/ruby/2.1.0/bin;C:/PROGRA~1/PUPPET~1/DevelopmentKit/bin 13 | 14 | $ENV:Path = (Join-Path $ENV:RUBY_DIR 'bin') + ';' + 15 | (Join-Path $ENV:LOCALAPPDATA 'PDK\cache\ruby\2.1.0\bin') + ';' + 16 | (Join-Path $ENV:DEVKIT_BASEDIR 'share\cache\ruby\2.1.0\bin') + ';' + 17 | (Join-Path $ENV:DEVKIT_BASEDIR 'bin') + ';' + $ENV:Path 18 | -------------------------------------------------------------------------------- /archive/devpooler.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | start powershell "& { Import-Module 'C:\Source\posh-vmpool\PSVMPooler\PSVMPooler.psm1'; Start-VMPoolerUI -URL 'https://vmpooler-dev.delivery.puppetlabs.net/api/v1' -Verbose }" -------------------------------------------------------------------------------- /archive/jenkins-experimental.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | #[switch]$EnableJobs, 3 | [switch]$DeleteJobs, 4 | [String]$FilterJobs = '.+' 5 | ) 6 | $ErrorActionPreference = 'Stop' 7 | 8 | Import-Module Jenkins 9 | 10 | $JenkinsURI = 'https://jenkins-master-prod-1.delivery.puppetlabs.net' 11 | $ExperimentalRegEx = '^experimental_auto_puppetlabs-' 12 | 13 | if ($DeleteJobs) { 14 | $Credential = Get-Credential -UserName 'glenn.sarti' -Message "Password for $JenkinsURI" 15 | 16 | Get-JenkinsJobList -Uri $JenkinsURI | 17 | ? { $_.name -match $ExperimentalRegEx } | 18 | ? { $_.name -match $FilterJobs } | 19 | % { 20 | $JobName = $_.name 21 | 22 | Write-Progress -Activity "Deleting Experimental Jobs" -CurrentOperation "Deleting $JobName" 23 | Remove-JenkinsJob -Uri $JenkinsURI -Credential $Credential -Name $JobName -Confirm:$false 24 | } 25 | 26 | } 27 | 28 | Get-JenkinsJobList -Uri $JenkinsURI | 29 | ? { $_.name -match $ExperimentalRegEx } | 30 | ? { $_.name -match $FilterJobs } | 31 | ft -Property name 32 | -------------------------------------------------------------------------------- /archive/pooler-local.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | start powershell "& { Import-Module 'C:\Source\posh-vmpool\PSVMPooler\PSVMPooler.psm1'; Start-VMPoolerUI -URL 'http://localhost:4567/api/v1' -Credential (Get-Credential 'glenn.sarti') -Verbose }" -------------------------------------------------------------------------------- /archive/pooler.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | start powershell "& { Import-Module 'C:\Source\posh-vmpool\PSVMPooler\PSVMPooler.psm1'; Start-VMPoolerUI -URL 'http://vmpooler.delivery.puppetlabs.net/api/v1' -Verbose }" -------------------------------------------------------------------------------- /archive/rubypwsh/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM drecom/ubuntu-ruby:2.5.0 2 | # Based on Ubuntu 16.04 3 | 4 | RUN apt-get update \ 5 | && apt-get install wget apt-transport-https -y \ 6 | && wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb \ 7 | && dpkg -i packages-microsoft-prod.deb \ 8 | && apt-get update \ 9 | && apt-get install -y powershell \ 10 | && apt-get install -y powershell 11 | 12 | CMD [ "irb" ] 13 | -------------------------------------------------------------------------------- /archive/rubypwsh/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | docker rmi glenn-pwshruby:2.5 4 | 5 | docker build --tag glenn-pwshruby:2.5 %~dp0 6 | -------------------------------------------------------------------------------- /archive/uber-ruby-installer.ps1: -------------------------------------------------------------------------------- 1 | param() 2 | 3 | $ErrorActionPreference = 'Stop' 4 | 5 | $is64bit = ([System.IntPtr]::Size -eq 8) 6 | 7 | if (-not $is64bit) { 8 | Throw "Script not supported on 32bit operating systems"; return 9 | } 10 | 11 | # Workaround for https://github.com/majkinetor/au/issues/142 12 | [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 13 | 768 -bor 14 | [System.Net.SecurityProtocolType]::Tls -bor 15 | [System.Net.SecurityProtocolType]::Ssl3 16 | 17 | $rubyList = @( 18 | '2.1.9', '2.1.9 (x64)', 19 | '2.4.4-2 (x86)', '2.4.4-2 (x64)', 20 | '2.5.1-2 (x86)', '2.5.1-2 (x64)' 21 | ) 22 | $devKit2_64 = 'C:\tools\DevKit2-x64' 23 | $devKit2_32 = 'C:\tools\DevKit2' 24 | $msys_64 = 'C:\tools\msys64' 25 | $msys_32 = 'C:\tools\msys32' 26 | 27 | function Get-UruTag($rubyVersion) { 28 | $bareRubyVersion = ($rubyVersion -split ' ')[0] 29 | 30 | if ($rubyVersion -match 'x64') { 31 | Write-Output "$($bareRubyVersion)-x64" 32 | } else { 33 | Write-Output "$($bareRubyVersion)-x86" 34 | } 35 | } 36 | 37 | Function Get-DestDir($rubyVersion) { 38 | Write-Output ("C:\tools\ruby" + $rubyVersion.Replace(' ','').Replace('(','').Replace(')','')) 39 | } 40 | 41 | # Instal chocolatey if it isn't already here... 42 | $ChocoExists = $false 43 | try { 44 | Get-Command 'choco.exe' | Out-Null 45 | $ChocoExists = $true 46 | } catch { 47 | $ChocoExists = $false 48 | } 49 | If (-not $ChocoExists) { 50 | Write-Host "Installing Chocolatey..." 51 | Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 52 | } else { Write-Host "Chocolatey is installed" -ForegroundColor Green} 53 | 54 | # 7Zip command line 55 | $7zExists = $false 56 | try { 57 | Get-Command '7z.exe' | Out-Null 58 | $7zExists = $true 59 | } catch { 60 | $7zExists = $false 61 | } 62 | If (-not $7zExists) { 63 | Write-Host "Installing 7Zip command line..." 64 | & choco install 7zip.commandline -y 65 | } else { Write-Host "7Zip is installed" -ForegroundColor Green} 66 | 67 | # URU 68 | if (-not (Test-Path -Path "$($ENV:ChocolateyInstall)\bin\uru.ps1")) { 69 | Write-Host "Installing URU..." 70 | Write-Host "Determining the current version of URU..." 71 | $uruver = (Invoke-WebRequest 'https://bitbucket.org/jonforums/uru/downloads/uru.json' -UseBasicParsing | ConvertFrom-JSON).version 72 | $downloadURL = "https://bitbucket.org/jonforums/uru/downloads/uru.${uruver}.nupkg" 73 | $uruRoot = 'C:\Tools' 74 | $uruInstall = Join-Path -Path $uruRoot -ChildPath 'URUInstall' 75 | $uruInstallNuget = Join-Path -Path $uruInstall -ChildPath 'uru.0.8.5.nupkg' 76 | if (Test-Path -Path $uruInstall) { Remove-Item -Path $uruInstall -Force -Recurse -Confirm:$false | Out-Null } 77 | New-Item -Path $uruInstall -ItemType Directory | Out-Null 78 | Write-Host "Downloading URU installer..." 79 | (New-Object System.Net.WebClient).DownloadFile($downloadURL, $uruInstallNuget) 80 | 81 | Write-Host "Running the URU installer..." 82 | choco install uru -source $uruInstall -f -y 83 | 84 | # Cleaning up... 85 | if (Test-Path -Path $uruInstall) { Remove-Item -Path $uruInstall -Force -Recurse -Confirm:$false | Out-Null } 86 | } else { Write-Host "Uru is installed" -ForegroundColor Green} 87 | 88 | # Prompt the user for which ruby versions to install 89 | $itemsToInstall = @() 90 | do { 91 | Write-Host "" 92 | Write-Host "" 93 | Write-Host "A. Install all versions ('$($rubyList -join "', '")')" 94 | For($index = 0; $index -lt $rubyList.Count; $index++) { 95 | Write-Host "$([char]($index + 66)). Install '$($rubyList[$index])'" 96 | } 97 | Write-Host "----" 98 | Write-Host "Z. Install custom version" 99 | Write-Host "" 100 | $misc = (Read-Host "Select an option").ToUpper() 101 | } until ( ($misc -ge 'A') -and $misc -le 'Z') 102 | 103 | $option = ([int][char]$misc - 65) 104 | switch ($option) { 105 | 0 { 106 | $itemsToInstall = $rubyList 107 | break; 108 | } 109 | 25 { 110 | # Ask the user for the version string 111 | do { 112 | $misc = '' 113 | Write-Host "" 114 | Write-Host "Note, the version must match one on the Ruby Installer archive website" 115 | Write-Host " https://rubyinstaller.org/downloads/archives/" 116 | $misc = (Read-Host "Enter Ruby version to install (e.g. '2.4.3-2 (x64)')") 117 | } until ($misc -ne '') 118 | $itemsToInstall = @($misc) 119 | } 120 | default { 121 | $itemsToInstall = @($rubyList[$option - 1]) 122 | } 123 | } 124 | 125 | if ( ($itemsToInstall -join '') -eq '' ) { Throw "Nothing to install!!"; return; } 126 | 127 | # Now we have the names of the rubies, time to install! 128 | $itemsToInstall | % { 129 | $rubyVersionString = $_ 130 | Write-Host "Installing Ruby ${rubyVersionString} ..." 131 | 132 | $rubyIs64 = $rubyVersionString -match 'x64' 133 | $rubyVersionString -match '^([\d.-]+)' | Out-Null 134 | $rubyVersion = $matches[1] 135 | 136 | $rubyURL = $null 137 | $32bitDevKit = $false 138 | $64bitDevKit = $false 139 | $RIDKDevKit = $false 140 | $destDir = Get-DestDir($rubyVersionString) 141 | $uruTag = Get-UruTag($rubyVersionString) 142 | 143 | # URL base page 144 | # https://rubyinstaller.org/downloads/archives/ 145 | switch -Regex ($rubyVersion) { 146 | '^2\.[0123]\.' { 147 | # Example URL 148 | # 32bit 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.3-i386-mingw32.7z' 149 | # 64bit 'https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.3-x64-mingw32.7z' 150 | if ($rubyIs64) { 151 | $rubyURL = "https://dl.bintray.com/oneclick/rubyinstaller/ruby-${rubyVersion}-x64-mingw32.7z" 152 | $64bitDevKit = $true 153 | } else { 154 | $rubyURL = "https://dl.bintray.com/oneclick/rubyinstaller/ruby-${rubyVersion}-i386-mingw32.7z" 155 | $32bitDevKit = $true 156 | } 157 | } 158 | '^2\.4\.1\-' { 159 | # Example URL 160 | # 2.4.1 only 161 | # 32bit 'https://github.com/oneclick/rubyinstaller2/releases/download/2.4.1-2/rubyinstaller-2.4.1-2-x86.7z' 162 | # 64bit 'https://github.com/oneclick/rubyinstaller2/releases/download/2.4.1-2/rubyinstaller-2.4.1-2-x64.7z' 163 | if ($rubyIs64) { 164 | $rubyURL = "https://github.com/oneclick/rubyinstaller2/releases/download/${rubyVersion}/rubyinstaller-${rubyVersion}-x64.7z" 165 | } else { 166 | $rubyURL = "https://github.com/oneclick/rubyinstaller2/releases/download/${rubyVersion}/rubyinstaller-${rubyVersion}-x86.7z" 167 | } 168 | $RIDKDevKit = $true 169 | } 170 | 171 | '^2\.[56789]\.|^2\.4\.[23456789]-' { 172 | # Example URL 173 | # 2.4.2+ and 2.5+ only 174 | # 32bit 'https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.1-1/rubyinstaller-2.5.1-1-x86.7z' 175 | # 64bit 'https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.1-1/rubyinstaller-2.5.1-1-x64.7z' 176 | if ($rubyIs64) { 177 | $rubyURL = "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-${rubyVersion}/rubyinstaller-${rubyVersion}-x64.7z" 178 | } else { 179 | $rubyURL = "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-${rubyVersion}/rubyinstaller-${rubyVersion}-x86.7z" 180 | } 181 | $RIDKDevKit = $true 182 | } 183 | default { Throw "Unknown Ruby Version $rubyVersion"; return } 184 | } 185 | 186 | # Install the ruby files 187 | if (-not (Test-Path -Path $destDir)) { 188 | $tempFile = Join-Path -path $ENV:Temp -ChildPath 'rubydl.7z' 189 | $tempExtract = Join-Path -path $ENV:Temp -ChildPath ('rubydl_extracted' + [guid]::NewGuid().ToString()) 190 | if (Test-Path -Path $tempExtract) { Start-Sleep -Seconds 2; Remove-Item -Path $tempExtract -Recurse -Confirm:$false -Force | Out-Null } 191 | 192 | Write-Host "Downloading from $rubyURL ..." 193 | if (Test-Path -Path $tempFile) { Start-Sleep -Seconds 2; Remove-Item -Path $tempFile -Confirm:$false -Force | Out-Null } 194 | Invoke-WebRequest -URI $rubyURL -OutFile $tempFile -UseBasicParsing 195 | 196 | & 7z x $tempFile "`"-o$tempExtract`"" -y 197 | 198 | # Get the root directory from the extract 199 | $misc = (Get-ChildItem -Path $tempExtract | ? { $_.PSIsContainer } | Select -First 1).Fullname 200 | 201 | Write-Host "Install ruby to $destDir ..." 202 | if (Test-Path -Path $destDir) { Remove-Item -Path $destDir -Recurse -Confirm:$false -Force | Out-Null } 203 | Move-Item -Path $misc -Destination $destDir -Force -Confirm:$false | Out-Null 204 | 205 | Write-Host "Adding to URU..." 206 | & uru admin add "$($destDir)\bin" --tag $uruTag 207 | 208 | Write-Host "Cleaning up..." 209 | if (Test-Path -Path $tempFile) { Remove-Item -Path $tempFile -Confirm:$false -Force | Out-Null } 210 | if (Test-Path -Path $tempExtract) { Remove-Item -Path $tempExtract -Recurse -Confirm:$false -Force | Out-Null } 211 | } else { Write-Host "Ruby ${rubyVersionString} is already installed to $destDir"} 212 | 213 | # Configure the ruby installation 214 | & uru $uruTag 215 | Write-Output "Ruby version..." 216 | & ruby -v 217 | Write-Output "Gem version..." 218 | & gem -v 219 | 220 | # Update the system gems 221 | $tempRC = Join-Path -path $ENV:Temp -ChildPath 'gem.rc' 222 | @" 223 | --- 224 | :backtrace: false 225 | :bulk_threshold: 1000 226 | :sources: 227 | - http://rubygems.org 228 | :update_sources: true 229 | :verbose: true 230 | "@ | Set-Content -Encoding Ascii -Path $tempRC -Force -Confirm:$false 231 | 232 | Write-Host "Updating system gems (via HTTP)..." 233 | if ($rubyVersion -match '^1\.') { 234 | & gem update --system --no-rdoc --config-file $tempRC 235 | } else { 236 | & gem update --system --no-rdoc --no-document --config-file $tempRC 237 | } 238 | Remove-Item -Path $tempRC -Force -Confirm:$false | Out-Null 239 | 240 | # Install bundler if it's not already there 241 | $BundleExists = $false 242 | try { 243 | Get-Command 'bundle' | Out-Null 244 | $BundleExists = $true 245 | } catch { 246 | $BundleExists = $false 247 | } 248 | if (-not $BundleExists) { 249 | Write-Host "Installing bundler..." 250 | if ($rubyVersion -match '^1\.') { 251 | & gem install bundler --no-ri --no-rdoc 252 | } else { 253 | & gem install bundler --no-ri --no-rdoc --no-document --force 254 | } 255 | } else { Write-Host "Bundler already installed" -ForegroundColor Green } 256 | 257 | # MSYS2 dev kit (Ruby 2.4+) 258 | if ($RIDKDevKit) { 259 | if ($rubyIs64) { 260 | # DevKit for Ruby 2.4+ 64bit 261 | if (-not (Test-Path -Path $msys_64)) { 262 | Write-Host "Installing DevKit 2.4+ x64" 263 | Start-Process -FilePath 'choco' -ArgumentList (@('install','msys2','-y','--params','/NoUpdate')) -NoNewWindow -Wait | Out-Null 264 | } else { Write-Host "DevKit 2.4+ 64bit is installed" -ForegroundColor Green } 265 | } else { 266 | # DevKit for Ruby 2.4+ 32bit 267 | if (-not (Test-Path -Path $msys_32)) { 268 | Write-Host "Installing DevKit 2.4+ x86" 269 | Start-Process -FilePath 'choco' -ArgumentList (@('install','msys2','-y','-x86','-f','--params','/NoUpdate')) -NoNewWindow -Wait | Out-Null 270 | } else { Write-Host "DevKit 2.4+ 32bit is installed" -ForegroundColor Green } 271 | } 272 | 273 | & ridk install 2 3 274 | } 275 | 276 | # 64 and 32 bit legacy DevKit 277 | if ($64bitDevKit -or $32bitDevKit) { 278 | #****************** 279 | # ORDER IS VERY IMPORTANT - 64bit Devkit MUST be installed before 32bit 280 | #****************** 281 | # DevKit for Ruby 2.x 64bit 282 | if ($is64bit -and (-not (Test-Path -Path $devKit2_64))) { 283 | Write-Host "Installing DevKit 2.x x64. NOTE - Errors are expected" 284 | Start-Process -FilePath 'choco' -ArgumentList (@('install','ruby2.devkit','-y')) -NoNewWindow -Wait | Out-Null 285 | if (-not (Test-Path -Path $devKit2_32)) { Throw "DevKit 2.x x64 did not install" } 286 | Move-Item $devKit2_32 $devKit2_64 -Force -EA Stop 287 | } else { Write-Host "DevKit 2.x 64bit is installed" -ForegroundColor Green } 288 | 289 | # DevKit for Ruby 2.x 32bit 290 | if (-not (Test-Path -Path $devKit2_32)) { 291 | Write-Host "Installing DevKit 2.x x86. NOTE - Errors are expected" 292 | Start-Process -FilePath 'choco' -ArgumentList (@('install','ruby2.devkit','-y','-x86','-f')) -NoNewWindow -Wait | Out-Null 293 | if (-not (Test-Path -Path $devKit2_32)) { Throw "DevKit 2.x x86 did not install" } 294 | } else { Write-Host "DevKit 2.x 32bit is installed" -ForegroundColor Green } 295 | 296 | # 64bit legacy devkit 297 | if ($64bitDevKit) { 298 | @" 299 | --- 300 | - $( $destDir -replace '\\','/' ) 301 | "@ | Set-Content -Path "$($devKit2_64)\config.yml" 302 | Push-Location $devKit2_64 303 | Write-Host "Installing DevKit $devKit2_64 for $rubyVersion" 304 | & ruby dk.rb install 305 | Pop-Location 306 | } 307 | 308 | # 32bit legacy devkit 309 | if ($32bitDevKit) { 310 | @" 311 | --- 312 | - $( $destDir -replace '\\','/' ) 313 | "@ | Set-Content -Path "$($devKit2_32)\config.yml" 314 | Push-Location $devKit2_32 315 | Write-Host "Installing DevKit $devKit2_32 for $rubyVersion" 316 | & ruby dk.rb install 317 | Pop-Location 318 | } 319 | } 320 | } 321 | 322 | Write-Host "Cleanup URU assignment" 323 | & uru nil 324 | 325 | Write-Host "Available ruby list" -ForegroundColor Green 326 | Write-Host "-------------------" -ForegroundColor Green 327 | & uru list 328 | -------------------------------------------------------------------------------- /base16-bright.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Bright", 3 | "description": "Bright scheme by Chris Kempson (http://chriskempson.com).", 4 | "repository": "https://github.com/mmims", 5 | "background": "Black", 6 | "foreground": "Green", 7 | "popupBackground": "Cyan", 8 | "popupForeground": "Gray", 9 | "palette": { 10 | "Black": "#010101", 11 | "DarkGray": "#909090", 12 | "Cyan": "#a9fdff", 13 | "Blue": "#a2caff", 14 | "Yellow": "#ffeb8b", 15 | "Green": "#eeffff", 16 | "Gray": "#eeffff", 17 | "White": "#ffffff", 18 | "DarkRed": "#f07178", 19 | "Red": "#f78c6c", 20 | "DarkYellow": "#ffcb6b", 21 | "DarkGreen": "#c3e88d", 22 | "DarkCyan": "#89ddff", 23 | "DarkBlue": "#82aaff", 24 | "DarkMagenta": "#c792ea", 25 | "Magenta": "#ff5370" 26 | }, 27 | "tokens": { 28 | "readline": { 29 | "foreground": { 30 | "Command": "DarkBlue", 31 | "Comment": "Yellow", 32 | "ContinuationPrompt": "Green", 33 | "DefaultToken": "Green", 34 | "Emphasis": "DarkCyan", 35 | "Error": "DarkRed", 36 | "Keyword": "DarkMagenta", 37 | "Member": "White", 38 | "Number": "White", 39 | "Operator": "Green", 40 | "Parameter": "Blue", 41 | "String": "DarkGreen", 42 | "Type": "DarkMagenta", 43 | "Variable": "Red" 44 | } 45 | }, 46 | "write": { 47 | "foreground": { 48 | "Error": "DarkRed", 49 | "Warning": "DarkYellow", 50 | "Verbose": "DarkYellow", 51 | "Debug": "DarkYellow", 52 | "Progress": "Yellow" 53 | }, 54 | "background": { 55 | "Progress": "DarkGray" 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /be.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | bundle exec %* 4 | 5 | EXIT /B %ERRORLEVEL% -------------------------------------------------------------------------------- /be.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bundle exec "$@" 4 | -------------------------------------------------------------------------------- /bi.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | RD .bundle\windows /s/q 4 | DEL .bundle\config /q /f 5 | del Gemfile.lock 6 | 7 | if [%1]==[] ( 8 | CALL bundle install --path .bundle\windows --without system_tests %* 9 | ) ELSE ( 10 | CALL bundle install --path .bundle\windows %* 11 | ) 12 | -------------------------------------------------------------------------------- /bi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf .bundle/bash 4 | rm .bundle/config 5 | rm Gemfile.lock 6 | 7 | if [ -z $1 ]; then 8 | bundle install --path .bundle/bash --with system_tests "$@" 9 | else 10 | bundle install --path .bundle/bash "$@" 11 | fi 12 | -------------------------------------------------------------------------------- /bq.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | ECHO Keeping existing bundle... 4 | 5 | del Gemfile.lock 6 | if [%1]==[] ( 7 | CALL bundle install --path .bundle\windows --without system_tests %* 8 | ) ELSE ( 9 | CALL bundle install --path .bundle\windows %* 10 | ) 11 | -------------------------------------------------------------------------------- /bq.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo keeping current bundle... 4 | rm Gemfile.lock 5 | 6 | bundle install --path .bundle/bash "$@" -------------------------------------------------------------------------------- /bundle.ps1: -------------------------------------------------------------------------------- 1 | $result = Get-Command ruby.exe 2 | $binPath = Split-Path -Path $result.Path -Parent 3 | 4 | & $result.Path $binPath/bundle $args 5 | -------------------------------------------------------------------------------- /convertallcrlf.txt: -------------------------------------------------------------------------------- 1 | gci -Recurse -file | % { $fname = $_.Fullname; Write-Output $fname; [IO.File]::WriteAllText($fname, ([IO.File]::ReadAllText($fname) -replace "`r`n", "`n")) } 2 | -------------------------------------------------------------------------------- /default-windowspowershell-profile.ps1: -------------------------------------------------------------------------------- 1 | param([Switch]$Install) 2 | 3 | $BinRoot = Join-Path $PSScriptRoot 'bin' 4 | if (-not (Test-Path -Path $BinRoot)) { New-Item -Path $BinRoot -ItemType Directory -Force -Confirm:$false | Out-Null } 5 | 6 | if ($Install) { 7 | $ProfileFile = $PROFILE 8 | $ProfilePath = Split-Path $ProfileFile -Parent 9 | if (-not (Test-Path -Path $ProfilePath)) { New-Item -Path $ProfilePath -ItemType Directory -Force -Confirm:$false | Out-Null } 10 | 11 | $PGit = Get-Module -ListAvailable | Where-Object { $_.Name -eq 'posh-git' } | Measure-Object 12 | 13 | if ($PGit.Count -eq 0) { 14 | Write-Host "Installing Posh-git..." 15 | Install-Module Posh-Git 16 | } 17 | 18 | Write-Host "Copying StarShip profile..." 19 | $StarShipDir = "~/.config" 20 | $StarShipFile = Join-Path $StarShipDir 'starship.toml' 21 | if (-not (Test-Path -Path $StarShipDir)) { New-Item -Path $StarShipDir -ItemType Directory -Force -Confirm:$false | Out-Null } 22 | Copy-Item (Join-Path $PSScriptRoot 'default_starship.toml') $StarShipFile -Force -Confirm:$false | Out-Null 23 | 24 | Function Install-StarShip { 25 | $ArchName = "" 26 | $OSName = "" 27 | $Suffix = "" 28 | 29 | #starship-x86_64-unknown-linux-gnu.tar.gz 30 | #starship-x86_64-pc-windows-msvc.zip 31 | #starship-aarch64-apple-darwin.tar.gz 32 | 33 | if ($PSVersionTable.Platform -eq 'Win32NT') { 34 | $ArchName = 'x86_64' 35 | $OSName = 'pc-windows' 36 | $Suffix = ".zip" 37 | } 38 | if ($PSVersionTable.Platform -eq 'Unix') { 39 | if ($PSVersionTable.OS -like '*Darwin*' -and $PSVersionTable.OS -like '*ARM64*') { 40 | $ArchName = 'aarch64' 41 | $OSName = 'apple-darwin' 42 | $Suffix = ".tar.gz" 43 | } else { 44 | $ArchName = 'x86_64' 45 | $OSName = 'unknown-linux' 46 | $Suffix = ".tar.gz" 47 | } 48 | } 49 | 50 | if ($ArchName -eq '' -or $OSname -eq '') { 51 | Write-Host "Could not determine which Starship package to download for '$($PSVersionTable.OS)'" 52 | return 53 | } 54 | 55 | Write-Host "Installing StarShip ($OSName $ArchName)..." 56 | $Url = 'https://api.github.com/repos/starship/starship/releases/latest' 57 | $GHRelease = Invoke-RestMethod $Url -Method Get 58 | 59 | # Note - Windows needs latest VCRuntime https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170 60 | # Get-Command VCRUNTIME140.dll 61 | $Asset = $GHRelease.assets | Where-Object { $_.name -like "*$ArchName*" -and $_.name -like "*$OSName*" -and $_.name -like "*$Suffix" } | Select-Object -First 1 62 | if ($null -eq $Asset) { Write-Host "Could not find a valid asset to download"; return } 63 | Write-Host "Downloading $($Asset.browser_download_url) ..." 64 | $TempFile = Join-Path $BinRoot 'starship.download' 65 | if (Test-Path -Path $TempFile) { Remove-Item $TempFile -Force -Confirm:$false | Out-Null } 66 | Invoke-WebRequest -Uri $Asset.browser_download_url -Method Get -UseBasicParsing -OutFile $TempFile 67 | 68 | if ($Suffix -eq '.zip') { 69 | Expand-Archive -Path $TempFile -DestinationPath $BinRoot 70 | } else { 71 | & tar -xvf $TempFile '--directory' $BinRoot 72 | } 73 | } 74 | 75 | if ( (Test-Path (Join-Path $BinRoot 'starship')) -or (Test-Path (Join-Path $BinRoot 'starship.exe')) ) { 76 | Write-Host "Starship is already installed" 77 | } else { 78 | Install-StarShip 79 | } 80 | 81 | # MUST BE LAST 82 | if (Test-Path -Path $ProfileFile) { 83 | $content = [System.IO.File]::ReadAllText( ( Resolve-Path $ProfileFile ) ) 84 | if ($content -like "*$PSCommandPath*") { 85 | Write-Host 'This script is already added to the PowerShell Profile' 86 | return 87 | } 88 | } 89 | 90 | Write-Host "Adding this script to the profile..." 91 | if (-not (Test-Path -Path $ProfileFile)) { 92 | ". `"$PSCommandPath`"" | Set-Content $ProfileFile -Encoding UTF8 -Force -Confirm:$false 93 | } else { 94 | "`n. `"$PSCommandPath`"" | Out-File $ProfileFile -Encoding UTF8 -Append -Force -Confirm:$false 95 | } 96 | 97 | return 98 | } 99 | 100 | If (($null -eq $ENV:ConEmuHWND) -and ($ENV:TERM_PROGRAM -ne 'vscode')) { 101 | # Import-Module PSConsoleTheme 102 | # Set-ConsoleTheme 'Bright' 103 | 104 | if ($PSVersionTable.Platform -eq 'Win32NT') { 105 | Set-Location C:\Source 106 | } else { 107 | Set-Location ~/code 108 | } 109 | } 110 | 111 | Function Test-Administrator { 112 | try { 113 | $CurrentUser = [Security.Principal.WindowsIdentity]::GetCurrent() 114 | $AdministratorRole = [Security.Principal.WindowsBuiltInRole] "Administrator" 115 | ([Security.Principal.WindowsPrincipal]$CurrentUser).IsInRole($AdministratorRole) 116 | } catch { 117 | # TODO: Catch this on non-Windows 118 | $False 119 | } 120 | } 121 | 122 | # Set ENV for elevated status 123 | If (Test-Administrator) { 124 | $Env:ISELEVATEDSESSION = 'just needs to be set, never displayed' 125 | } 126 | 127 | Import-Module Posh-Git 128 | $ENV:PATH = $ENV:PATH + [IO.Path]::PathSeparator + $PSScriptRoot 129 | 130 | # Turn on starship! 🚀🚀🚀 131 | $StarshipExe = Join-Path $BinRoot 'starship' 132 | if ($PSVersionTable.Platform -eq 'Win32NT') { $StarshipExe = $StarshipExe + '.exe' } 133 | Invoke-Expression (& $StarshipExe init powershell) 134 | -------------------------------------------------------------------------------- /default_starship.toml: -------------------------------------------------------------------------------- 1 | format =""" 2 | ${env_var.is_elevated_session}$username@$hostname $git_branch$git_commit$git_state$git_status 3 | $ruby$rust$golang$dotnet$directory""" 4 | 5 | # Inserts a blank line between shell prompts 6 | add_newline = true 7 | 8 | # Make it a tad faster than 500 9 | command_timeout = 1500 10 | 11 | # LINE ONE 12 | 13 | [env_var.is_elevated_session] # TODO: Turn this into a custom env_var once implemented 14 | variable = "ISELEVATEDSESSION" 15 | symbol = '⚡' 16 | format = "[$symbol](bold bright-yellow)" 17 | 18 | [username] 19 | format = "[$user](bg:black)" 20 | disabled = false 21 | show_always = true 22 | 23 | [hostname] 24 | ssh_only = false 25 | format = "$hostname" 26 | 27 | ## Virtual Working Environment: 28 | ##TODO: virtual env: vagrant, docker 29 | 30 | [git_branch] 31 | symbol = " -> " 32 | always_show_remote = true 33 | format = "on [$branch$symbol$remote_name/$remote_branch]($style) " 34 | 35 | [git_commit] 36 | tag_disabled = false 37 | 38 | [git_state] 39 | # No overrides 40 | 41 | [git_status] 42 | # Show the info relative to the upstream first: how many commits ahead/behind/diverged/conflicted 43 | # Show the info for current working set after: deleted, staged, renamed, modified, untracked. 44 | format = "$ahead$behind$diverged$conflicted$deleted$staged$renamed$modified$untracked" 45 | conflicted = "[≠$count ](bold purple)" 46 | ahead = "[⇡$count ](bold purple)" 47 | behind = "[⇣$count ](bold purple)" 48 | diverged = "[⇕$count ](bold purple)" 49 | untracked = "[+$count ](bold blue)" 50 | modified = "[~$count ](bold cyan)" 51 | staged = "[++$count ](bold green)" 52 | renamed = "[»$count ](bold white)" 53 | deleted = "[✘$count ](bold red)" 54 | 55 | # LINE TWO 56 | [character] 57 | success_symbol = "[ ✓](bold bg:black fg:green)" 58 | error_symbol = "[ ✗](bold bg:black fg:bright-purple)" 59 | 60 | [directory] 61 | truncation_length = 3 62 | truncate_to_repo = false 63 | read_only = "🧾" 64 | format = "[$read_only$path > ](fg:cyan)" 65 | 66 | ## Languages: 67 | -------------------------------------------------------------------------------- /dockruby.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | docker run -i --tty --rm -v "%CD%:/project" -v "C:\Source\dev-tools:/tools" ruby:2.1 bash 4 | -------------------------------------------------------------------------------- /getpr.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(DefaultParameterSetName='interactive')] 2 | param( 3 | [Parameter(Mandatory = $true, ParameterSetName = "uri")] 4 | [Alias("uri", "github")] 5 | [ValidateNotNullOrEmpty()] 6 | [String] $GithubURI, 7 | 8 | [Parameter(Mandatory = $false, ParameterSetName = "interactive")] 9 | [String] $Owner = '', 10 | 11 | [Parameter(Mandatory = $false, ParameterSetName = "interactive")] 12 | [String] $Project = '', 13 | 14 | [Parameter(Mandatory = $false, ParameterSetName = "interactive")] 15 | [Int] $PullRequest = -1 16 | ) 17 | 18 | $CurrentDir = (Get-Location).Path 19 | 20 | switch ($PsCmdlet.ParameterSetName) { 21 | 'uri' { 22 | $arrURI = $GithubURI -split '/' 23 | 24 | $Owner = $arrURI[3] 25 | $Project = $arrURI[4] 26 | $PullRequest = [Int]$arrURI[6] 27 | 28 | } 29 | 'interactive' { 30 | if ($Owner -eq '') { $Owner = Read-Host -Prompt "Enter the project owner" } 31 | if ($Project -eq '') { $Project = Read-Host -Prompt "Enter the project name" } 32 | if ($PullRequest -eq -1) { $PullRequest = Read-Host -Prompt "Enter the PR number" } 33 | } 34 | } 35 | 36 | # Get the base branch 37 | Write-Verbose "Attempting to the get PR information at https://api.github.com/repos/$Owner/$Project/pulls/$PullRequest" 38 | $PRInfo = Invoke-RestMethod -URI "https://api.github.com/repos/$Owner/$Project/pulls/$PullRequest" -ErrorAction Stop 39 | $Branch = $PRInfo.base.ref 40 | 41 | Write-Verbose "PR Owner = $Owner" 42 | Write-Verbose "PR Project = $Project" 43 | Write-Verbose "PR Branch = $Branch" 44 | Write-Verbose "PR Number = $PullRequest" 45 | 46 | $TargetDir = Join-Path -Path $CurrentDir -ChildPath "$Project-pr$PullRequest" 47 | if (Test-Path -Path $TargetDir) { Remove-Item -Path $TargetDir -Recurse -Force -Confirm:$false | Out-Null } 48 | 49 | Write-Verbose "Cloning..." 50 | & git clone "https://github.com/$Owner/$Project.git" $TargetDir 51 | 52 | Push-Location $TargetDir 53 | 54 | Write-Verbose "Fetching PR..." 55 | & git fetch origin "refs/pull/$PullRequest/head:pr_$PullRequest" 56 | 57 | Write-Verbose "Changing to intended branch..." 58 | & git checkout $Branch 59 | 60 | Write-Verbose "Merging PR..." 61 | & git merge "pr_$PullRequest" --no-ff 62 | 63 | Pop-Location 64 | -------------------------------------------------------------------------------- /lastdocker.ps1: -------------------------------------------------------------------------------- 1 | param($Command = '/bin/bash') 2 | $Containers = (&docker ps --format '{{.ID}}') 3 | 4 | if ($Containers.GetType().ToString() -ne 'System.String') { Throw "There are either no containers, or more than one container running" } 5 | 6 | & docker exec -it $Containers $Command 7 | -------------------------------------------------------------------------------- /powerline.psm1: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env powershell 2 | 3 | # from https://gist.github.com/Jaykul/2388b845cca0ef219b434d8c5e2c26ea 4 | # Also needs fonts from https://github.com/powerline/fonts/ 5 | # Also maybe http://poshcode.org/6338 6 | 7 | using namespace System.Collections.Generic 8 | 9 | class PowerLineOutput { 10 | [Nullable[ConsoleColor]]$BackgroundColor 11 | [Nullable[ConsoleColor]]$ForegroundColor 12 | [Object]$Content 13 | [bool]$Clear = $false 14 | 15 | PowerLineOutput() {} 16 | 17 | PowerLineOutput([hashtable]$values) { 18 | foreach($key in $values.Keys) { 19 | if("bg" -eq $key -or "BackgroundColor" -match "^$key") { 20 | $this.BackgroundColor = $values.$key 21 | } 22 | elseif("fg" -eq $key -or "ForegroundColor" -match "^$key") { 23 | $this.ForegroundColor = $values.$key 24 | } 25 | elseif("fg" -eq $key -or "ForegroundColor" -match "^$key") { 26 | $this.ForegroundColor = $values.$key 27 | } 28 | elseif("text" -match "^$key" -or "Content" -match "^$key") { 29 | $this.Content = $values.$key 30 | } 31 | elseif("Clear" -match "^$key") { 32 | $this.Clear = $values.$key 33 | } 34 | else { 35 | throw "Unknown key '$key' in hashtable. Allowed values are BackgroundColor, ForegroundColor, Content, and Clear" 36 | } 37 | } 38 | } 39 | 40 | [string] GetText() { 41 | if($this.Content -is [scriptblock]) { 42 | return & $this.Content 43 | } else { 44 | return $this.Content 45 | } 46 | } 47 | 48 | [string] ToString() { 49 | return $( 50 | if($this.BackgroundColor) { 51 | [PowerLineOutput]::EscapeCodes.bg."$($this.BackgroundColor)" 52 | } else { 53 | [PowerLineOutput]::EscapeCodes.bg.Clear 54 | } 55 | ) + $( 56 | if($this.ForegroundColor) { 57 | [PowerLineOutput]::EscapeCodes.fg."$($this.ForegroundColor)" 58 | } else { 59 | [PowerLineOutput]::EscapeCodes.fg.Clear 60 | } 61 | ) + $this.GetText() + $( 62 | if($this.Clear) { 63 | [PowerLineOutput]::EscapeCodes.bg.Clear 64 | [PowerLineOutput]::EscapeCodes.fg.Clear 65 | } 66 | ) 67 | } 68 | 69 | static [PowerLineOutput] $NewLine = [PowerLineOutput]@{Content="`n"} 70 | static [PowerLineOutput] $ShiftRight = [PowerLineOutput]@{Content="`t"} 71 | static [hashtable] $EscapeCodes = @{ 72 | ESC = ([char]27) + "[" 73 | CSI = [char]155 74 | Clear = ([char]27) + "[0m" 75 | fg = @{ 76 | Clear = ([char]27) + "[39m" 77 | Black = ([char]27) + "[30m"; DarkGray = ([char]27) + "[90m" 78 | DarkRed = ([char]27) + "[31m"; Red = ([char]27) + "[91m" 79 | DarkGreen = ([char]27) + "[32m"; Green = ([char]27) + "[92m" 80 | DarkYellow = ([char]27) + "[33m"; Yellow = ([char]27) + "[93m" 81 | DarkBlue = ([char]27) + "[34m"; Blue = ([char]27) + "[94m" 82 | DarkMagenta = ([char]27) + "[35m"; Magenta = ([char]27) + "[95m" 83 | DarkCyan = ([char]27) + "[36m"; Cyan = ([char]27) + "[96m" 84 | Gray = ([char]27) + "[37m"; White = ([char]27) + "[97m" 85 | } 86 | bg = @{ 87 | Clear = ([char]27) + "[49m" 88 | Black = ([char]27) + "[40m"; DarkGray = ([char]27) + "[100m" 89 | DarkRed = ([char]27) + "[41m"; Red = ([char]27) + "[101m" 90 | DarkGreen = ([char]27) + "[42m"; Green = ([char]27) + "[102m" 91 | DarkYellow = ([char]27) + "[43m"; Yellow = ([char]27) + "[103m" 92 | DarkBlue = ([char]27) + "[44m"; Blue = ([char]27) + "[104m" 93 | DarkMagenta = ([char]27) + "[45m"; Magenta = ([char]27) + "[105m" 94 | DarkCyan = ([char]27) + "[46m"; Cyan = ([char]27) + "[106m" 95 | Gray = ([char]27) + "[47m"; White = ([char]27) + "[107m" 96 | } 97 | } 98 | } 99 | 100 | class PowerLineOutputCache : PowerLineOutput { 101 | [string]$Content 102 | [int]$Length 103 | 104 | PowerLineOutputCache([PowerLineOutput] $output) { 105 | 106 | $this.BackgroundColor = $output.BackgroundColor 107 | $this.ForegroundColor = $output.ForegroundColor 108 | $this.Content = $output.GetText() 109 | $this.Length = $this.Content.Length 110 | } 111 | } 112 | 113 | class PowerLine { 114 | [bool]$SetTitle = $true 115 | [bool]$SetCwd = $true 116 | [List[PowerLineOutput]]$Prompt = @( 117 | [PowerLineOutput]@{ bg = "blue"; fg = "white"; text = { $MyInvocation.HistoryId } } 118 | [PowerLineOutput]@{ bg = "cyan"; fg = "white"; text = { "$GEAR" * $NestedPromptLevel } } 119 | [PowerLineOutput]@{ bg = "darkblue"; fg = "white"; text = { $pwd.Drive.Name } } 120 | [PowerLineOutput]@{ bg = "darkblue"; fg = "white"; text = { Split-Path $pwd -leaf } } 121 | ) 122 | } 123 | 124 | $global:PowerLine = [PowerLine]::new() 125 | 126 | [PowerLineOutput]::EscapeCodes.fg.Default = [PowerLineOutput]::EscapeCodes.fg."$($Host.UI.RawUI.ForegroundColor)" 127 | [PowerLineOutput]::EscapeCodes.fg.Background = [PowerLineOutput]::EscapeCodes.fg."$($Host.UI.RawUI.BackgroundColor)" 128 | [PowerLineOutput]::EscapeCodes.bg.Default = [PowerLineOutput]::EscapeCodes.bg."$($Host.UI.RawUI.BackgroundColor)" 129 | 130 | 131 | function Get-Elapsed { 132 | [CmdletBinding()] 133 | param( 134 | [Parameter()] 135 | [int]$Id, 136 | 137 | [Parameter()] 138 | [string]$Format = "{0:h\:mm\:ss\.ffff}" 139 | ) 140 | $LastCommand = Get-History -Count 1 @PSBoundParameters 141 | if(!$LastCommand) { return "" } 142 | $Duration = $LastCommand.EndExecutionTime - $LastCommand.StartExecutionTime 143 | $Format -f $Duration 144 | } 145 | 146 | function ConvertTo-ANSI { 147 | [CmdletBinding(DefaultParameterSetName="ConsoleColor")] 148 | param( 149 | [Parameter(ValueFromPipelineByPropertyName, ParameterSetName="ConsoleColor")] 150 | [Alias("fg")] 151 | [ConsoleColor]$ForegroundColor, 152 | 153 | [Parameter(ValueFromPipelineByPropertyName, ParameterSetName="ConsoleColor")] 154 | [Alias("bg")] 155 | [ConsoleColor]$BackgroundColor, 156 | 157 | [Parameter(Position=0)] 158 | [Alias("text")] 159 | $text, 160 | 161 | [Alias("length")] 162 | $ignored, 163 | 164 | [switch]$Clear 165 | ) 166 | 167 | if($BackgroundColor) { 168 | [PowerLineOutput]::EscapeCodes.bg."$BackgroundColor" 169 | } else { 170 | [PowerLineOutput]::EscapeCodes.bg.Clear 171 | } 172 | 173 | if($ForegroundColor) { 174 | [PowerLineOutput]::EscapeCodes.fg."$ForegroundColor" 175 | } else { 176 | [PowerLineOutput]::EscapeCodes.fg.Clear 177 | } 178 | 179 | # Output the actual text 180 | if($text -is [scriptblock]) { 181 | & $text 182 | } else { 183 | $text 184 | } 185 | if($Clear) { 186 | [PowerLineOutput]::EscapeCodes.bg.Clear 187 | [PowerLineOutput]::EscapeCodes.fg.Clear 188 | } 189 | } 190 | 191 | function Set-PowerLinePrompt { 192 | # Here is an example of a prompt which needs access to a global value 193 | # Get-Location -Stack in the module would never return anything ... 194 | $function:global:prompt = { 195 | Write-PowerLine $global:PowerLine 196 | } 197 | } 198 | 199 | function Write-PowerLine { 200 | [CmdletBinding()] 201 | param([PowerLine]$PowerLine) 202 | 203 | # FIRST, make a note if there was an error in the previous command 204 | $err = !$? 205 | $e = ([char]27) + "[" 206 | # PowerLine font characters 207 | $RIGHT = [char]0xe0b0 # Solid, right facing triangle 208 | $GT = [char]0xe0b1 # right facing triangle 209 | $LEFT = [char]0xe0b2 # Solid, right facing triangle 210 | $LT = [char]0xe0b3 # right facing triangle 211 | $BRANCH = [char]0xe0a0 # Branch symbol 212 | $LOCK = [char]0xe0a2 # Padlock 213 | $RAQUO = [char]0x203a # Single right-pointing angle quote ? 214 | $GEAR = [char]0x2699 # The settings icon, I use it for debug 215 | $EX = [char]0x27a6 # The X that looks like a checkbox. 216 | $POWER = [char]0x26a1 # The Power lightning-bolt icon 217 | $MID = [char]0xB7 # Mid dot (I used to use this for pushd counters) 218 | 219 | try { 220 | if($PowerLine.SetTitle) { 221 | # Put the path in the title ... (don't restrict this to the FileSystem) 222 | $Host.UI.RawUI.WindowTitle = "{0} - {1} ({2})" -f $global:WindowTitlePrefix, (Convert-Path $pwd), $pwd.Provider.Name 223 | } 224 | if($PowerLine.SetCwd) { 225 | # Make sure Windows & .Net know where we are 226 | # They can only handle the FileSystem, and not in .Net Core 227 | [Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath 228 | } 229 | } catch {} 230 | 231 | # Initialize things that need to be ... 232 | $width = [Console]::BufferWidth 233 | $leftLength = 0 234 | $rightLength = 0 235 | $lineCount = 0 236 | $anchored = $false 237 | 238 | # Precalculate all the text and remove empty blocks 239 | $blocks = ([PowerLineOutputCache[]]$PowerLine.Prompt) | Where Length 240 | 241 | if($Host.UI.SupportsVirtualTerminal) { 242 | $(&{ 243 | # If we can use advanced ANSI sequences, we can do more 244 | # Like output on the previous line(s) 245 | if($blocks[0] -is [int] -and $blocks[0] -lt 0) 246 | { 247 | $lineCount = $blocks[0] 248 | "${e}1A" * [Math]::Abs($lineCount) 249 | $block, $blocks = $blocks 250 | } 251 | 252 | # Loop through and output 253 | # Depends on access to previous and future blocks, so this can't be refactored to a function 254 | for($l=0; $l -lt $blocks.Length; $l++) { 255 | $block = $blocks[$l] 256 | if($block -eq [PowerLineOutput]::NewLine) { 257 | $lineCount++ 258 | $leftLength = 0 259 | $rightLength = 0 260 | "`n" 261 | } elseif($block -eq [PowerLineOutput]::ShiftRight) { 262 | # the length of the rest of the line 263 | $rightLength = ($(for($r=$l+1; $r -lt $blocks.Length -and $blocks[$r] -is [hashtable]; $r++) { 264 | $blocks[$r].length + 1 265 | }) | Measure-Object -Sum).Sum 266 | 267 | $space = $width - $rightLength 268 | 269 | # add the caps at the end of the left-side, and beginning of the right side, like: > ... < 270 | if($leftLength) { 271 | # the left cap uses the Background of the previous block as it's foreground 272 | [PowerLineOutput]@{ 273 | ForegroundColor = ($blocks[($l-1)]).BackgroundColor 274 | Content = $RIGHT 275 | Clear = $true 276 | } 277 | } 278 | 279 | if($lineCount -eq 0) { 280 | $anchored = $true 281 | "${e}s" 282 | } 283 | "${e}${space}G" 284 | 285 | # the right cap uses the background of the next block as it's foreground 286 | [PowerLineOutput]@{ 287 | ForegroundColor = ($blocks[($l+1)]).BackgroundColor 288 | Content = $LEFT 289 | } 290 | } else { 291 | if($leftLength -eq 0 -and $rightLength -eq 0) { 292 | # On a new line, recalculate the length of the "left-aligned" line 293 | $leftLength = ($(for($r=$l; $r -lt $blocks.Length -and $blocks[$r] -ne [PowerLineOutput]::NewLine -and $blocks[$r] -ne [PowerLineOutput]::ShiftRight; $r++) { 294 | $blocks[$r].length + 1 295 | }) | Measure-Object -Sum).Sum 296 | } 297 | 298 | $block 299 | # Put out a separator 300 | if($blocks[($l+1)] -ne [PowerLineOutput]::NewLine -and $blocks[($l+1)] -ne [PowerLineOutput]::ShiftRight) 301 | { 302 | if($block.BackgroundColor -eq $blocks[($l+1)].BackgroundColor) { 303 | $GT 304 | } else { 305 | [PowerLineOutput]@{ 306 | ForegroundColor = $block.BackgroundColor 307 | BackgroundColor = $blocks[($l+1)].BackgroundColor 308 | Content = $RIGHT 309 | } 310 | } 311 | } 312 | } 313 | } 314 | 315 | # move the prompt location to the end of output unless it's anchored already 316 | if($lineCount -le 0 -and !$anchored) { 317 | "${e}s" 318 | } 319 | 320 | # With ANSI VT support, restore the original prompt position 321 | if($anchored) {"${e}u"} # RECALL LOCATION 322 | else { 323 | [PowerLineOutput]@{ 324 | ForegroundColor = $blocks[-1].BackgroundColor 325 | Content = $RIGHT 326 | } 327 | } 328 | [PowerLineOutput]::EscapeCodes.fg.Default 329 | }) -join "" 330 | 331 | } else { 332 | for($l=0; $l -lt $blocks.Length; $l++) { 333 | $block = $blocks[$l] 334 | if($block -is [string]) { 335 | if($block -eq "`n") { 336 | $lineCount++ 337 | $leftLength = 0 338 | $rightLength = 0 339 | Write-Host 340 | } elseif($block -eq "`t") { 341 | # the length of the rest of the line 342 | $rightLength = ($(for($r=$l+1; $r -lt $blocks.Length -and $blocks[$r] -is [hashtable]; $r++) { 343 | $blocks[$r].length + 1 344 | }) | Measure-Object -Sum).Sum 345 | $space = $width - $rightLength - $leftLength 346 | 347 | if($leftLength) { 348 | $last = $blocks[($l-1)] 349 | $c = @{} 350 | if($last.bg) { $c.ForegroundColor = $last.bg } 351 | if($last.fg) { $c.BackgroundColor = $last.fg } 352 | Write-Host -NoNewLine $RIGHT @c 353 | } 354 | 355 | Write-Host -NoNewLine (" " * ${space}) 356 | 357 | if($rightLength) { 358 | $next = $blocks[($l+1)] 359 | $c = @{} 360 | if($next.bg) { $c.ForegroundColor = $next.bg } 361 | if($next.fg) { $c.BackgroundColor = $next.fg } 362 | Write-Host -NoNewLine $LEFT @c 363 | } 364 | } 365 | } else { 366 | if($leftLength -eq 0 -and $rightLength -eq 0) { 367 | # On a new line, recalculate the length of the "left-aligned" line 368 | $leftLength = ($(for($r=$l; $r -lt $blocks.Length -and $blocks[$r] -is [hashtable]; $r++) { 369 | $blocks[$r].length + 1 370 | }) | Measure-Object -Sum).Sum 371 | } 372 | 373 | $c = @{} 374 | if($block.fg) { $c.ForegroundColor = $block.fg } 375 | if($block.bg) { $c.BackgroundColor = $block.bg } 376 | Write-Host -NoNewLine $block.Text @c 377 | if($blocks[($l+1)] -is [hashtable]) 378 | { 379 | if($block.bg -eq $blocks[($l+1)].bg) { 380 | Write-Host $GT -NoNewLine @c 381 | } else { 382 | $c = @{} 383 | $c.ForegroundColor = if($block.bg) { $block.bg } else { [PowerLineOutput]::EscapeCodes.bg.Default } 384 | if($block.bg) { $c.BackgroundColor = $blocks[($l+1)].bg } 385 | Write-Host -NoNewLine $RIGHT @c 386 | } 387 | } 388 | } 389 | } 390 | # if there's anything on the right and there's no ANSI VT support, put the prompt on the next line 391 | if($rightLength) { 392 | Write-Host "`n$RIGHT" -NoNewLine 393 | } 394 | } 395 | } -------------------------------------------------------------------------------- /powerpoint.ps1: -------------------------------------------------------------------------------- 1 | 2 | $title = (get-process POWERPNT -ErrorAction 'SilentlyContinue' | Select-Object -First 1).MainWindowTitle 3 | 4 | if ($null -eq $title) { return } 5 | $wshell = New-Object -ComObject wscript.shell; 6 | $wshell.AppActivate($title) 7 | Start-Sleep 1 8 | $wshell.SendKeys('+{F5}') 9 | -------------------------------------------------------------------------------- /pryme.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | COPY /Y "%~dp0Gemfile.local" "./Gemfile.local" 4 | 5 | echo "You have been pry'd" -------------------------------------------------------------------------------- /pryme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp -f "/mnt/c/Source/dev-tools/Gemfile.local" "./Gemfile.local" 4 | 5 | echo "You have been pry'd" -------------------------------------------------------------------------------- /scpsync-ubuntu.script: -------------------------------------------------------------------------------- 1 | 2 | # open sftp://administrator:Qu%40lity%21@%1% -hostkey="*" 3 | open sftp://root@%1% -hostkey="*" "-privatekey=C:\Users\glenn.sarti\.ssh\id_vmpooler.ppk" 4 | 5 | option batch continue 6 | mkdir "/project" 7 | option batch abort 8 | 9 | synchronize remote "%2%" "/project" -filemask="|.bundle/;.git/;Gemfile.lock;log/;junit/;*/spec/fixtures/modules/;*/tmp/;*/.vscode-test/;*/.vscode/;*/node_modules/" 10 | 11 | keepuptodate "%2%" "/project" -nopermissions -filemask="|.bundle/;.git/;Gemfile.lock;log/;junit/;*/spec/fixtures/modules/;*/tmp/;*/.vscode-test/;*/.vscode/;*/node_modules/" -delete 12 | 13 | exit 14 | -------------------------------------------------------------------------------- /scpsync-ubunutu.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | $target = '', 3 | $destDir = '', 4 | [Switch]$PrepTarget 5 | ) 6 | $ErrorActionPreference = 'Stop' 7 | 8 | # choco install openssh -y -params '"/SSHServerFeature"' 9 | 10 | $thisDir = Get-Location 11 | if ($destDir -eq '') { $destDir = '/source/' + (Split-Path -Path (Get-Location) -Leaf) } 12 | 13 | if ($PrepTarget) { 14 | Write-Host "Preparing Target machine..." 15 | 16 | Invoke-Command -ComputerName $target -Credential (Get-Credential 'Administrator') -ArgumentList @($destDir) -ScriptBlock { 17 | param($destDir) 18 | if (-Not (Test-Path -Path $destDir)) { 19 | Write-Host "Creating destination dir..." 20 | New-Item $destDir -ItemType Directory | Out-Null 21 | } 22 | 23 | & choco install openssh -y -params '"/SSHServerFeature"' 24 | } 25 | } 26 | 27 | Write-Host "Connecting to $target ..." 28 | & "C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script=C:\Source\dev-tools\scpsync-ubuntu.script /parameter $target ($thisDir -replace '\\','/') ($destDir -replace '\\','/') 29 | 30 | #Write-Host ($target, ($thisDir -replace '\\','/'), ($destDir -replace '\\','/')) 31 | -------------------------------------------------------------------------------- /scpsync.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | $target = '', 3 | $destDir = '', 4 | [Switch]$PrepTarget 5 | ) 6 | $ErrorActionPreference = 'Stop' 7 | 8 | # choco install openssh -y -params '"/SSHServerFeature"' 9 | 10 | $thisDir = Get-Location 11 | if ($destDir -eq '') { $destDir = $thisDir } 12 | 13 | if ($PrepTarget) { 14 | Write-Host "Preparing Target machine..." 15 | 16 | Invoke-Command -ComputerName $target -Credential (Get-Credential 'Administrator') -ArgumentList @($destDir) -ScriptBlock { 17 | param($destDir) 18 | if (-Not (Test-Path -Path $destDir)) { 19 | Write-Host "Creating destination dir..." 20 | New-Item $destDir -ItemType Directory | Out-Null 21 | } 22 | 23 | & choco install openssh -y -params '"/SSHServerFeature"' 24 | } 25 | } 26 | 27 | Write-Host "Connecting to $target ..." 28 | & "C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script=C:\Source\dev-tools\scpsync.script /parameter $target ($thisDir -replace '\\','/') ($destDir -replace '\\','/') 29 | -------------------------------------------------------------------------------- /scpsync.script: -------------------------------------------------------------------------------- 1 | 2 | open sftp://Administrator:Password1@%1% -hostkey="*" 3 | 4 | option batch continue 5 | mkdir "%3%" 6 | option batch abort 7 | 8 | synchronize remote "%2%" "%3%" -filemask="|.bundle/;.git/;Gemfile.lock;log/;junit/;*/spec/fixtures/modules/;*/tmp/;*/.vscode-test;*/vscode;*/node_modules" 9 | 10 | keepuptodate "%2%" "%3%" -nopermissions -filemask="|.bundle/;.git/;Gemfile.lock;log/;junit/;*/spec/fixtures/modules/;*/tmp/;*/.vscode-test;*/vscode;*/node_modules" -delete 11 | 12 | exit 13 | -------------------------------------------------------------------------------- /ssh.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | "C:\Program Files\Git\usr\bin\ssh.exe" %* -------------------------------------------------------------------------------- /update-system-gems.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | ECHO Updating system gems (via HTTP) 4 | 5 | ECHO Using http for gem sources ... 6 | call gem sources -r https://rubygems.org/ 7 | call gem sources -a http://rubygems.org/ 8 | 9 | ECHO Updating... 10 | call gem update --system 11 | 12 | ECHO Restoring gem sources... 13 | call gem sources -r http://rubygems.org/ 14 | call gem sources -a https://rubygems.org/ 15 | -------------------------------------------------------------------------------- /uru-save.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | ruby -v > .ruby-version --------------------------------------------------------------------------------