feat: initial commit

This commit is contained in:
root 2025-04-01 17:40:03 +00:00
commit 2dfb19d1a1
457 changed files with 40577 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# this file checks the status of the Windows Docker package using the DockerProvider powershell provider
$dockerProviderName="DockerProvider"
Write-Information "Checking Docker package."
$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore
if ($package -ne $null) {
Exit 1
}
$service = Get-Service "docker" -ErrorAction Ignore
if ($service -ne $null) {
exit 1
}
if (Test-Path -Path "$env:ProgramFiles\docker") {
exit 1
}
exit 0

View file

@ -0,0 +1,22 @@
$dockerLocation = Join-Path $env:TEMP "docker.zip"
if ((test-path $dockerLocation))
{
$localModified = (Get-Item $dockerLocation).LastWriteTime
$webRequest = [System.Net.HttpWebRequest]::Create("<%= $docker_download_url %>");
$webRequest.Method = "HEAD";
$webResponse = $webRequest.GetResponse()
$remoteLastModified = ($webResponse.LastModified) -as [DateTime]
$webResponse.Close()
if ($remoteLastModified -gt $localModified)
{
exit 1
}
else
{
exit 0
}
}
exit 1

View file

@ -0,0 +1,17 @@
#file computes the 512SHA for a given string and writes it to a file
$String = $env:docker_auth
$HashName = "SHA512"
$StringBuilder = New-Object System.Text.StringBuilder
[System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))|%{
[Void]$StringBuilder.Append($_.ToString("x2"))
}
if([System.IO.File]::Exists("<%= $passfile %>")){
$CurrentContent = Get-Content -Path "<%= $passfile %>"
if($CurrentContent -eq $StringBuilder.ToString()){
exit 0
}
}
exit 1

View file

@ -0,0 +1,48 @@
# this file checks the status of the Windows Docker package using the DockerProvider powershell provider
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerProviderName="DockerProvider"
Write-Information "Checking Package Provider"
$module = Get-PackageProvider NuGet -ErrorAction SilentlyContinue
If ($module -eq $null) {
Write-Error "NuGet PackagePrivider is not installed."
Exit 1
}
<% if $nuget_package_provider_version { -%>
Write-Information "Checking Package provider version"
if ($module.Version.ToString() -ne "<%= $nuget_package_provider_version %>" ) {
Write-Error "Incorrect Microsoft Nuget provider version installed"
Exit 1
}
<% } -%>
Write-Information "Checking Docker Provider"
$provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction SilentlyContinue
If ($provider -eq $null) {
Write-Error "Docker Microsoft Docker provider is not installed."
Exit 1
}
<% if $docker_msft_provider_version { -%>
Write-Information "Checking Docker provider version"
if ($provider.Version.ToString() -ne "<%= $docker_msft_provider_version %>" ) {
Write-Error "Incorrect Microsoft Docker Provider version installed."
Exit 1
}
<% } -%>
Write-Information "Checking Docker package."
$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction SilentlyContinue
If ($package -eq $null) {
Write-Error "Docker package is not installed."
Exit 1
}
<% if $version { -%>
Write-Information "Checking Docker package version"
if ($package.Version.ToString() -notmatch "<%= $version %>"){
Write-Error "Incorrect Docker package version installed."
Exit 1
}
<% } %>

View file

@ -0,0 +1,10 @@
#file computes the 512SHA for a given string and writes it to a file
$String = $env:docker_auth
$HashName = "SHA512"
$StringBuilder = New-Object System.Text.StringBuilder
[System.Security.Cryptography.HashAlgorithm]::Create($HashName).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($String))|%{
[Void]$StringBuilder.Append($_.ToString("x2"))
}
$StringBuilder.ToString() | Out-File <%= $passfile %>

View file

@ -0,0 +1,23 @@
{
<% if $dns { %> "dns": <%= $dns_array.to_json %>,<% } -%>
<% if $dns_search { %> "dns-search": <%= $dns_search_array.to_json %>,<% } -%>
<% if $log_driver { %> "log-driver": "<%= $log_driver %>", <% } -%>
<% if $mtu { %> "mtu": <%= $mtu %>,<% } -%>
<% if $tcp_bind { %> "hosts": <%= $tcp_bind_array.to_json %>,<% } -%>
<% if $log_level { %> "log-level": "<%= $log_level %>",<% } -%>
<% if $tls_enable { %> "tlsverify": true,
"tlscacert": "<%= $tls_cacert %>",
"tlscert": "<%= $tls_cert %>",
"tlskey": "<%= $tls_key %>",
<% } -%>
<% if $socket_group { %>"group": "<%= $socket_group %>",<% } -%>
<% if $bridge { %>"bridge": "<%= $bridge %>",<% } -%>
<% if $fixed_cidr { %>"fixed-cidr": "<%= $fixed_cidr %>",<% } -%>
<% if type($registry_mirror, 'generalized') == String { %>"registry-mirrors": ["<%= $registry_mirror %>"], <% } -%>
<% if String(type($registry_mirror, 'generalized')).index('Array') == 0 { %>"registry-mirrors": ["<%= $registry_mirror.join('", "') %>"], <% } -%>
<% if $extra_parameters { %><% $extra_parameters_array.each |$param| { %>
<%= $param %> ,<% } %>
<% } -%>
<% if $root_dir { %>"data-root": "<%= $root_dir %>",<% } -%>
"labels": <%= $labels_array.to_json %>
}

View file

@ -0,0 +1,40 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerLocation = Join-Path $env:TEMP "docker.zip"
Invoke-webrequest -UseBasicparsing -Outfile $dockerLocation "<%= $docker_download_url %>"
$cleanInstall = $false
$service = Get-Service "docker" -ErrorAction Ignore
if ( -not $service ) {
$cleanInstall = $true
} elseif ( $service.Status -ne [ServiceProcess.ServiceControllerStatus]::Stopped ) {
$timeSpan = New-Timespan -Seconds 60
try {
$service.Stop()
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Stopped, $timeSpan)
}
catch [Management.Automation.MethodInvocationException],[ServiceProcess.TimeoutException] {
Write-Error "Failed to stop docker service"
exit 1
}
}
# Extract the archive.
Expand-Archive -Force $dockerLocation -DestinationPath $Env:ProgramFiles
# Install Docker. This will require rebooting.
$null = Install-WindowsFeature containers
if ($cleanInstall) {
# Add Docker to the path for the current session.
$env:path += ";$env:ProgramFiles\docker"
# Optionally, modify PATH to persist across sessions.
$newPath = "$env:ProgramFiles\docker;" + [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::Machine)
# Register the Docker daemon as a service.
dockerd --register-service
}

View file

@ -0,0 +1,23 @@
try {
$WebClient = New-Object System.Net.WebClient
<%if $proxy { %>
$uri = New-Object Uri("<%= $proxy %>")
if ($uri.UserInfo -eq $null) {
$WebProxy = New-Object System.Net.WebProxy("<%= $proxy %>",$true)
$WebClient.Proxy = $WebProxy
}
else {
$user,$password = $uri.UserInfo -split (':')
$proxyAddress = $uri.Scheme + "://" + $uri.Host + ":" + $uri.Port + $uri.PathAndQuery
$WebProxy = New-Object System.Net.WebProxy($uri,$true)
$WebClient.Proxy = $WebProxy
$WebClient.Proxy.Credentials = New-Object System.Net.NetworkCredential($user, $password)
}
<% } %>
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WebClient.DownloadFile("<%= $docker_compose_url %>","<%= $docker_compose_location_versioned %>")
}
catch {
exit 1
}
exit 0

View file

@ -0,0 +1,23 @@
try {
$WebClient = New-Object System.Net.WebClient
<%if $proxy { %>
$uri = New-Object Uri("<%= $proxy %>")
if ($uri.UserInfo -eq $null) {
$WebProxy = New-Object System.Net.WebProxy("<%= $proxy %>",$true)
$WebClient.Proxy = $WebProxy
}
else {
$user,$password = $uri.UserInfo -split (':')
$proxyAddress = $uri.Scheme + "://" + $uri.Host + ":" + $uri.Port + $uri.PathAndQuery
$WebProxy = New-Object System.Net.WebProxy($uri,$true)
$WebClient.Proxy = $WebProxy
$WebClient.Proxy.Credentials = New-Object System.Net.NetworkCredential($user, $password)
}
<% } %>
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$WebClient.DownloadFile("<%= $docker_machine_url %>","<%= $docker_machine_location_versioned %>")
}
catch {
exit 1
}
exit 0

View file

@ -0,0 +1,28 @@
# this file install the Windows Docker package using the DockerProvider powershell provider
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dockerProviderName="DockerProvider"
Write-Information "Installing Package Provider"
$module = Install-PackageProvider NuGet -Force <% if $nuget_package_provider_version { %><%= "-RequiredVersion ${nuget_package_provider_version}" %><% } %>
If ($module -eq $null) {
Write-Error "Failed to install NuGet Package Provider"
Exit 1
}
Write-Information "Installing Docker Provider"
Install-Module $dockerProviderName -Force <% if $docker_msft_provider_version { %><%= "-RequiredVersion ${docker_msft_provider_version}" %><% } %>
$provider = Get-Module -ListAvailable -Name $dockerProviderName
If ($provider -eq $null) {
Write-Error "Failed to install Docker Microsoft Provider"
Exit 1
}
Write-Information "Installing Docker Package"
$package=Install-Package Docker -ProviderName $dockerProviderName -Force <% if $version { %><%= "-RequiredVersion ${version}" %><% } %>
If ($package -eq $null) {
Write-Error "Failed to install Docker Package"
Exit 1
}

View file

@ -0,0 +1,48 @@
# this file install the Windows Docker package using the DockerProvider powershell provider
$dockerProviderName="DockerProvider"
$package=Get-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -ErrorAction Ignore
If ($package -ne $null) {
Write-Information "Uninstalling Docker Package"
$package=Uninstall-Package <%= $docker_ee_package_name %> -ProviderName $dockerProviderName -Force
<% if $version { -%>
-RequiredVersion <%= $version %>
<% } -%>
If ($package -eq $null) {
Write-Error "Failed to uninstall Docker Package"
Exit 1
}
}
$provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction Ignore
If ($provider -ne $null) {
Write-Information "Uninstalling Docker Provider"
Uninstall-Module $dockerProviderName -Force
$provider = Get-Module -ListAvailable -Name $dockerProviderName -ErrorAction Ignore
If ($provider -ne $null) {
Write-Error "Failed to uninstall Docker Microsoft Provider"
Exit 1
}
}
$service = Get-Service "docker" -ErrorAction Ignore
if ($service -ne $null) {
if ( $service.Status -ne [ServiceProcess.ServiceControllerStatus]::Stopped ) {
$timeSpan = New-Object Timespan 0,0,60
try {
$service.Stop()
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Stopped, 60)
}
catch [Management.Automation.MethodInvocationException],[ServiceProcess.TimeoutException] {
Write-Error "Failed to stop docker service"
exit 1
}
}
sc.exe delete "docker"
}
if (Test-Path -Path "$env:ProgramFiles\docker") {
Remove-Item "$env:ProgramFiles\docker" -Recurse -Force
}

View file

@ -0,0 +1,27 @@
# Pulls a docker image.
# Returns 0 if there a change.
# Returns 2 if there is no change.
# Returns 3 if something when wrong.
#
param
(
[string]$DockerImage
)
Write-Information "Before - Looking for image"
$before=$(& <%= $docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null)
Write-Information "Pulling image"
& <%= $docker_command %> pull ${DockerImage}
Write-Information "Inspecting image"
$after=$(& <%= $docker_command %> inspect --type image --format='{{.Id}}' ${DockerImage} 2>$null)
If (!$after) {
Write-Information "Docker image ${DockerImage} failed to pull!"
Exit 3
} ElseIf ($after -eq $before) {
Write-Information "No updates to ${DockerImage} available. Currently on ${after}."
Exit 2
} Else {
Write-Information "${DockerImage} updated. Changed from ${before} to ${after}."
Exit 0
}