Skip to content

Commit

Permalink
move things around
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf committed Jan 11, 2025
1 parent c77a83e commit d3c1d56
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 67 deletions.
67 changes: 2 additions & 65 deletions init/start-builder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,6 @@ function GetConf {
}
}

function ConfigureSmbRights {
$tmpfile = "c:\tmp\secpol.cfg"
secedit /export /cfg $tmpfile
$secpol = (Get-Content $tmpfile)

$Value = $secpol | Where-Object{ $_ -like "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth" }
$Index = [array]::IndexOf($secpol,$Value)
if ($Index -eq -1) {
$Index = [array]::IndexOf($secpol, "[Registry Values]")
$idx2 = $Index + 1
$NewValue = "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth=4,1"
$newpol = $secpol[0..$Index]
$newpol += ($NewValue)
$newpol += $secpol[$idx2..$secpol.Length]
$secpol = $newpol
} else {
$NewValue = "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth=4,1"
$secpol.item($Index) = $NewValue
}

$secpol | out-file $tmpfile -Force
secedit /configure /db c:\windows\security\local.sdb /cfg $tmpfile
Remove-Item -Path $tmpfile

gpupdate /Force
}

function InitializeAgentConfig {
Write-Host "Setting up Grafana Agent"
$config = Get-Content -Path "/tmp/infra/grafana/agent-win.yaml"
Expand Down Expand Up @@ -105,44 +78,8 @@ function MountZ {
}
}

function GetResolvedIPAddress {
param(
[string] $Hostname
)

$resolved = Resolve-DnsName -Name $hostname
$first = $resolved[0]
if (!$first.IPAddress) {
return (GetResolvedIPAddress $first.NameHost)
} else {
return $first.IPAddress
}
}

function AddToHosts {
param(
[string] $Hostname
)

$ip = GetResolvedIPAddress $hostname

$content = Get-Content "C:\Windows\System32\drivers\etc\hosts"
$content = $content,($ip + " " + $Hostname)
Set-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value $content

return $ip
}

function AddLocalHost {
$content = Get-Content "C:\Windows\System32\drivers\etc\hosts"
$content = $content,("127.0.0.1 localhost")
Set-Content -Path "C:\Windows\System32\drivers\etc\hosts" -Value $content
}

ConfigureSmbRights

MountZ

InitializeAgentConfig

FetchInfra

InitializeAgentConfig
29 changes: 27 additions & 2 deletions packer/InstallBuilderTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function InstallBuildTools {
AllowAppContainerRXAccess -Path "C:\BuildTools\Ninja"
}


function InstallPython {
# note: conan 1.59 won't install with Python 3.12 (because of a dependency), so we use the last 3.10 where there's a .exe
Write-Host "Downloading python"
Expand All @@ -78,7 +77,6 @@ function InstallPython {
$env:PATH = "C:\BuildTools\Python;C:\BuildTools\Python\Scripts;$env:PATH"
}


function InstallConan {
Write-Host "Installing conan"
python -m pip install conan==1.59
Expand All @@ -88,7 +86,34 @@ function InstallConan {
conan remote add ceserver https://conan.compiler-explorer.com/ True
}

function ConfigureSmbRights {
$tmpfile = "c:\tmp\secpol.cfg"
secedit /export /cfg $tmpfile
$secpol = (Get-Content $tmpfile)

$Value = $secpol | Where-Object{ $_ -like "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth" }
$Index = [array]::IndexOf($secpol,$Value)
if ($Index -eq -1) {
$Index = [array]::IndexOf($secpol, "[Registry Values]")
$idx2 = $Index + 1
$NewValue = "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth=4,1"
$newpol = $secpol[0..$Index]
$newpol += ($NewValue)
$newpol += $secpol[$idx2..$secpol.Length]
$secpol = $newpol
} else {
$NewValue = "MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\AllowInsecureGuestAuth=4,1"
$secpol.item($Index) = $NewValue
}

$secpol | out-file $tmpfile -Force
secedit /configure /db c:\windows\security\local.sdb /cfg $tmpfile
Remove-Item -Path $tmpfile

gpupdate /Force
}

ConfigureSmbRights
InstallAwsTools
InstallGIT
InstallBuildTools
Expand Down

0 comments on commit d3c1d56

Please sign in to comment.