From 99086d241d9cec91794dfa291a3b829fad4c8ba1 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Mon, 6 Jan 2025 16:24:19 -0500 Subject: [PATCH] Add TriggerInstall.ps1 --- TriggerInstall.ps1 | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 TriggerInstall.ps1 diff --git a/TriggerInstall.ps1 b/TriggerInstall.ps1 new file mode 100644 index 0000000..1c38c51 --- /dev/null +++ b/TriggerInstall.ps1 @@ -0,0 +1,83 @@ +// priority + +async function triggerInstall() { + const dropdown = document.getElementById('dattoRmmDropdown'); + const UID = dropdown.options[dropdown.selectedIndex].value; + const Name = dropdown.options[dropdown.selectedIndex].text; + + const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]'); + const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]'); + const installDattoRMM = document.querySelector('input[name="installDattoRMM"]'); + const installCyberQP = document.querySelector('input[name="installCyberQP"]'); + const installSplashtop = document.querySelector('input[name="installSplashtop"]'); + const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]'); + const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]'); + const installThreatLocker = document.querySelector('input[name="installThreatLocker"]'); + const installRocketCyber = document.querySelector('input[name="installRocketCyber"]'); + + async function executeFetch(url, options = {}) { + try { + appendLog(`Starting ${url}...`, "cyan"); + const response = await fetch(url, options); + if (!response.ok) throw new Error(`Failed at ${url}: ${response.statusText}`); + appendLog(`${url} completed successfully.`, "green"); + } catch (error) { + appendLog(`Error: ${error.message}`, "red"); + } + } + + // Priority 1: Install SVSMSP Module + if (installSVSMSPModule.checked) { + await executeFetch('/installSVSMSPModule', { method: 'GET' }); + } + + // Priority 2: Install DattoRMM + if (installDattoRMM.checked) { + const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked'); + appendLog("Installing selected site RMM (Priority 2)...", "cyan"); + + const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value); + const payload = { + checkedValues, // Array of selected checkbox values + UID, // Selected site UID + Name // Selected site name + }; + + await executeFetch('/installrmm', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }); + } + + // Lower-priority tasks + if (setSVSPowerplan.checked) { + await executeFetch('/SetSVSPowerplan', { method: 'GET' }); + } + + if (installCyberQP.checked) { + await executeFetch('/installCyberQP', { method: 'GET' }); + } + + if (installSplashtop.checked) { + await executeFetch('/installSplashtop', { method: 'GET' }); + } + + if (installSVSHelpDesk.checked) { + await executeFetch('/installSVSHelpDesk', { method: 'GET' }); + } + + if (installSVSWatchtower.checked) { + await executeFetch('/installSVSWatchtower', { method: 'GET' }); + } + + if (installThreatLocker.checked) { + await executeFetch('/installThreatLocker', { method: 'GET' }); + } + + if (installRocketCyber.checked) { + await executeFetch('/installRocketCyber', { method: 'GET' }); + } + + appendLog("All tasks completed.", "green"); +}