Skip to content

Commit aca4ecc

Browse files
committed
[PE Helper/PXE Helpers] Remove unused APIs from FOG Helper
1 parent 0361fee commit aca4ecc

File tree

1 file changed

+21
-60
lines changed

1 file changed

+21
-60
lines changed

Helpers/extps1/PE_Helper/pxehelpers/fog/foghelper_server.ps1

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,39 @@
2929
#
3030
# Exposed APIs:
3131
#
32-
# - /api/installimages --> Gets the install images in the FOG store
33-
# - /api/connect --> Connects a client to a server
32+
# - /api/foghome --> The Control Panel
33+
# - /api/fogsetup --> Configures the FOG PowerShell module to communicate with the FOG server
34+
# - /api/hosts --> Gets all the registered hosts in the FOG server
35+
# - /api/getImagesForHost --> Gets all the images that are associated to a given host
3436
#
35-
# A client must send data to /api/connect like this (example in PowerShell):
37+
# A client must send data to /api/getImagesForHost like this (example in PowerShell):
3638
#
3739
# $json = @{
38-
# deviceId = "<Device ID>"
40+
# hostId = "<Host ID in FOG server>"
3941
# } | ConvertTo-Json
4042
#
41-
# - /api/deploy --> Prepares a server for image deployment to a client
43+
# - /api/getAllImages --> Gets all the registered images in the FOG server
44+
# - /api/deploy --> Initiates a deployment task on the FOG server
4245
#
4346
# A client must send data to /api/deploy like this (example in PowerShell):
4447
#
4548
# $json = @{
46-
# shareGuid = "<GUID for share, obtained with /api/connect>"
47-
# image_name = "<File name of image in FOG>"
48-
# image_group = "<FOG image group>"
49+
# hostId = "<Host ID in FOG server>"
50+
# imageId = "<Image ID in FOG server>"
4951
# } | ConvertTo-Json
5052
#
51-
# This must then be sent as part of the body. Then, mount a network share that will be created to the WinPE
53+
# - /api/setDhcp --> (Windows Server ONLY) Sets the IP address in the DHCP server to initiate the second stage of image deployment (Linux-based)
5254
#
53-
# - /api/clearfiles --> Clears all the files created during deployment preparation
54-
# - /api/exit --> Gracefully close the program
55+
# A client must send data to /api/setDhcp like this (example in PowerShell):
56+
#
57+
# $json = @{
58+
# fogIp = "<IP of underlying FOG server>"
59+
# } | ConvertTo-Json
60+
#
61+
# This is only valid when starting the WINDOWS version of this script.
62+
#
63+
# - /api/viewlogs --> Views the logs recorded by the script (ONLY ACCESSIBLE BY SERVERS. DO NOT ACCESS ON CLIENTS!)#
64+
# - /api/exit --> Gracefully close the program
5565
#
5666
# Settings for the server are declared in the Server Options section.
5767

@@ -60,8 +70,6 @@
6070
# ----------------------- Server Options -----------------------
6171
$webHost = "*"
6272
$port = 8080
63-
$tmpImageFolderPath = "$env:SystemDrive\NetInstallFOGTemp"
64-
$shareName = "NetInstallTemp"
6573
# --------------------------------------------------------------
6674

6775
function Write-LogMessage {
@@ -132,13 +140,6 @@ Write-Host "(c) 2025. CodingWonders Software"
132140
Write-Host "-----------------------------------------------------------"
133141

134142
Write-LogMessage -message "Checking operating environment..."
135-
136-
if ([Environment]::OSVersion.Platform -ne "Win32NT") {
137-
Write-Host "This script cannot be run on non-Windows NT platforms. Press ENTER to exit..."
138-
Read-Host | Out-Null
139-
return $false
140-
}
141-
142143
$compInfo = Get-ComputerInfo
143144
if ($compInfo.WindowsInstallationType -ne "Server") {
144145
Write-LogMessage -message "This computer is not running Windows Server."
@@ -165,8 +166,6 @@ Write-LogMessage -message "Starting FOG Helper Web API..."
165166
Write-LogMessage -message "Server Options:"
166167
Write-LogMessage -message " - Web API Host: $webHost"
167168
Write-LogMessage -message " - Web API Port to listen to: $port"
168-
Write-LogMessage -message " - Temporary directory for deployment operations: $tmpImageFolderPath"
169-
Write-LogMessage -message " - Name for SMB network share: $shareName"
170169
Write-LogMessage -message "Creating firewall rules..."
171170
$fwRule = $null
172171
try {
@@ -390,14 +389,6 @@ try {
390389
<tr>
391390
<td colspan="2" class="super_duper_important_tab">IMPORTANT! You will need to provide the aforementioned information when connecting from clients</td>
392391
</tr>
393-
<tr>
394-
<td class="important_tab">Temporary folder for network shares:</td>
395-
<td>$tmpImageFolderPath</td>
396-
</tr>
397-
<tr>
398-
<td class="important_tab">Share Name:</td>
399-
<td>$shareName</td>
400-
</tr>
401392
</table>
402393
</fieldset>
403394
<fieldset>
@@ -583,36 +574,6 @@ try {
583574
$sendJson.Invoke(@{ error = "Method not allowed" }, 405)
584575
}
585576
}
586-
"/api/installimages" {
587-
if ($request.HttpMethod -eq "GET") {
588-
try {
589-
$images = Get-FOGInstallImages
590-
$sendJson.Invoke(@{ success = $true; images = $images })
591-
} catch {
592-
Write-LogMessage -message "Exception caught: $_"
593-
$sendJson.Invoke(@{ success = $false; error = $_.Exception.Message }, 500)
594-
}
595-
} else {
596-
$sendJson.Invoke(@{ error = "Method not allowed" }, 405)
597-
}
598-
}
599-
"/api/connect" {
600-
if ($request.HttpMethod -eq "POST") {
601-
try {
602-
$reader = New-Object IO.StreamReader $request.InputStream
603-
$body = $reader.ReadToEnd() | ConvertFrom-Json
604-
$deviceId = $body.deviceId
605-
606-
$result = Start-ServerConnection -deviceId $deviceId
607-
if ($result -ne $null) {
608-
$sendJson.Invoke(@{ success = $result.successful; output = $result })
609-
}
610-
} catch {
611-
Write-LogMessage -message "Exception caught: $_"
612-
$sendJson.Invoke(@{ success = $false; error = $_.Exception.Message }, 500)
613-
}
614-
}
615-
}
616577
"/api/deploy" {
617578
if ($request.HttpMethod -eq "POST") {
618579
try {

0 commit comments

Comments
 (0)