<commit_before># bootstrap.ps1
#
# Installs needed files to bootstrap a fresh windows server installation for game hosting.
# Based on the chocolatey installer script from https://chocolatey.org/install.ps1
# For more information: https://github.com/JonathanPorta/windows-bootstrap
#

# Make sure we have a temp directory
$tmpDir = 'C:\tmp'
if (![System.IO.Directory]::Exists($tmpDir)) {[System.IO.Directory]::CreateDirectory($tmpDir)}

# define a downloader function to make downloading easier
function DoFileDownload {
param (
  [string]$url,
  [string]$file
 )
  Write-Host "Preparing to download $url to $file..."
  Write-Host "Checking if $file already exists..."

  If (Test-Path $file){
    Write-Host "Not downloading because $file already exists..."
  }
  Else{
    Write-Host "Downloading $url to $file..."
    $downloader = new-object System.Net.WebClient
    $downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
    $downloader.DownloadFile($url, $file)
  }
}

# download windows-bootstrap repo
Write-Host "Download windows-bootstrap files..."
$bootstrapArchive = Join-Path $tmpDir "bootstrap.zip"
DoFileDownload 'https://github.com/JonathanPorta/windows-bootstrap/archive/master.zip' $bootstrapArchive

# download 7zip
Write-Host "Download 7Zip commandline tool..."
$7zaExe = Join-Path $tmpDir '7za.exe'
DoFileDownload 'https://chocolatey.org/7za.exe' "$7zaExe"

# unzip the package
Write-Host "Extracting $bootstrapArchive to $tmpDir..."
Start-Process "$7zaExe" -ArgumentList "x -o`"$tmpDir`" -y `"$bootstrapArchive`"" -Wait -NoNewWindow

# define installer path vars
$bootstrapDir = Join-Path $tmpDir 'windows-bootstrap-master'
$toolsDir = Join-Path $bootstrapDir 'powershell'
$chefDir = Join-Path $bootstrapDir 'chef-solo'
$installer = Join-Path $bootstrapDir 'install.ps1'

# define chef path vars
# TODO: abstract this config to make it easier to provision other server types
$cookbookUrl = 'https://github.com/JonathanPorta/rust-server-cookbook.git'
$cookbookPath = 'C:\cookbooks\rust'
$cookbookRef = 'master'

# Start the installation
Write-Host "Begin installation..."
iex $installer
<commit_msg>Update ps scripts<commit_after># bootstrap.ps1
#
# Installs needed files to bootstrap a fresh windows server installation for game hosting.
# Based on the chocolatey installer script from https://chocolatey.org/install.ps1
# For more information: https://github.com/JonathanPorta/windows-bootstrap
#

# Make sure we have a temp directory
$tmpDir = 'C:\tmp'
if (![System.IO.Directory]::Exists($tmpDir)) {[System.IO.Directory]::CreateDirectory($tmpDir)}

# define a downloader function to make downloading easier
function DoFileDownload {
param (
  [string]$url,
  [string]$file,
  [bool]$overwrite=$true
 )
  Write-Host "Preparing to download $url to $file..."
  Write-Host "Checking if $file already exists..."

  If (Test-Path $file && !$overwrite){
    Write-Host "Not downloading because $file already exists..."
  }
  Else{
    Write-Host "Downloading $url to $file..."
    $downloader = new-object System.Net.WebClient
    $downloader.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
    $downloader.DownloadFile($url, $file)
  }
}

# download windows-bootstrap repo
Write-Host "Download windows-bootstrap files..."
$bootstrapArchive = Join-Path $tmpDir "bootstrap.zip"
DoFileDownload 'https://github.com/JonathanPorta/windows-bootstrap/archive/master.zip' $bootstrapArchive

# download 7zip
Write-Host "Download 7Zip commandline tool..."
$7zaExe = Join-Path $tmpDir '7za.exe'
DoFileDownload 'https://chocolatey.org/7za.exe' "$7zaExe"

# unzip the package
Write-Host "Extracting $bootstrapArchive to $tmpDir..."
Start-Process "$7zaExe" -ArgumentList "x -o`"$tmpDir`" -y `"$bootstrapArchive`"" -Wait -NoNewWindow

# define installer path vars
$bootstrapDir = Join-Path $tmpDir 'windows-bootstrap-master'
$toolsDir = Join-Path $bootstrapDir 'powershell'
$chefDir = Join-Path $bootstrapDir 'chef-solo'
$installer = Join-Path $bootstrapDir 'install.ps1'

# define chef path vars
# TODO: abstract this config to make it easier to provision other server types
$cookbookUrl = 'https://github.com/JonathanPorta/rust-server-cookbook.git'
$cookbookPath = 'C:\cookbooks\rust'
$cookbookRef = 'master'

# Start the installation
Write-Host "Begin installation..."
iex $installer

{'fraction_non_alphanumeric': 0.12578334825425247, 'fraction_numerical': 0.004476275738585497, 'mean_word_length': 4.226900584795322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1915862', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1374, 'n_words': 370}