Update StackMonkey.ps1

This commit is contained in:
2025-06-22 23:59:34 -04:00
parent 54cf3a1f19
commit cff7f6e4a5

View File

@@ -62,6 +62,14 @@
#> #>
# Listening port for HTTP UI
$Port = 8082
# Configurable endpoints
$Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
function Invoke-ScriptMonkey { function Invoke-ScriptMonkey {
#region ScriptMonkey run silently Entrypoint #region ScriptMonkey run silently Entrypoint
[CmdletBinding(DefaultParameterSetName='UI')] [CmdletBinding(DefaultParameterSetName='UI')]
@@ -72,6 +80,10 @@ function Invoke-ScriptMonkey {
[switch]$SilentInstall, [switch]$SilentInstall,
# ───────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────
[Parameter(Mandatory,ParameterSetName='Datto')]
[string] $N8nPassword,
<# replaced by n8n
# Datto headless mode # Datto headless mode
[Parameter(Mandatory,ParameterSetName='Datto')] [Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()] #[ValidateNotNullOrEmpty()]
@@ -84,6 +96,7 @@ function Invoke-ScriptMonkey {
[Parameter(Mandatory,ParameterSetName='Datto')] [Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()] #[ValidateNotNullOrEmpty()]
[string] $DattoApiSecretKey, [string] $DattoApiSecretKey,
#>
[Parameter(Mandatory,ParameterSetName='Datto')] [Parameter(Mandatory,ParameterSetName='Datto')]
#[ValidateNotNullOrEmpty()] #[ValidateNotNullOrEmpty()]
@@ -110,11 +123,19 @@ function Invoke-ScriptMonkey {
return return
} }
'Datto' { 'Datto' {
Write-LogHelper "Headless DattoRMM deploy" Info Startup Write-LogHelper "Headless DattoRMM deploy (via n8n)" Info Startup
# 1) fetch creds from n8n
$creds = Get-DattoApiCredentials -Password $N8nPassword
if (-not $creds) {
throw "Failed to retrieve Datto API credentials from n8n"
}
# 2) pass them straight into the helper
Install-DattoRMM-Helper ` Install-DattoRMM-Helper `
-ApiUrl $DattoApiUrl ` -ApiUrl $creds.ApiUrl `
-ApiKey $DattoApiKey ` -ApiKey $creds.ApiKey `
-ApiSecretKey $DattoApiSecretKey ` -ApiSecretKey $creds.ApiSecretKey `
-SiteUID $SiteUID ` -SiteUID $SiteUID `
-SiteName $SiteName ` -SiteName $SiteName `
-PushSiteVars:$PushSiteVars ` -PushSiteVars:$PushSiteVars `
@@ -140,11 +161,6 @@ function Invoke-ScriptMonkey {
#region Config & Task Definitions #region Config & Task Definitions
# Listening port for HTTP UI
$Port = 8082
# Configurable endpoints
$Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
# Define every task once here: # Define every task once here:
@@ -279,10 +295,9 @@ function Respond-JSON {
#region Get-DattoApiCreds #region Get-DattoApiCreds
function Get-DattoApiCredentials { function Get-DattoApiCredentials {
param ([string]$Password) param ([string]$Password)
$url = "https://automate.svstools.ca/webhook/svsmspkit"
$headers = @{ "SVSMSPKit" = $Password } $headers = @{ "SVSMSPKit" = $Password }
try { try {
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method GET $response = Invoke-RestMethod -Uri $Global:DattoWebhookUrl -Headers $headers -Method GET
return @{ return @{
ApiUrl = $response.ApiUrl ApiUrl = $response.ApiUrl
ApiKey = $response.ApiKey ApiKey = $response.ApiKey