mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Start and stop safe-chain agent's Windows service.
This commit is contained in:
parent
dba101daa7
commit
2a649c5ef8
1 changed files with 22 additions and 1 deletions
|
|
@ -38,13 +38,18 @@ async function installOnWindows() {
|
||||||
ui.writeVerbose(`Destination: ${msiPath}`);
|
ui.writeVerbose(`Destination: ${msiPath}`);
|
||||||
await downloadFile(downloadUrl, msiPath);
|
await downloadFile(downloadUrl, msiPath);
|
||||||
|
|
||||||
|
stopServiceIfRunning();
|
||||||
|
|
||||||
ui.writeInformation("Installing SafeChain Agent...");
|
ui.writeInformation("Installing SafeChain Agent...");
|
||||||
ui.writeVerbose(`Running: msiexec /i "${msiPath}" /qn`);
|
ui.writeVerbose(`Running: msiexec /i "${msiPath}" /qn`);
|
||||||
runMsiInstaller(msiPath);
|
runMsiInstaller(msiPath);
|
||||||
|
|
||||||
|
ui.writeInformation("Starting SafeChain Agent service...");
|
||||||
|
startService();
|
||||||
|
|
||||||
ui.writeVerbose(`Cleaning up temporary file: ${msiPath}`);
|
ui.writeVerbose(`Cleaning up temporary file: ${msiPath}`);
|
||||||
cleanup(msiPath);
|
cleanup(msiPath);
|
||||||
ui.writeInformation("SafeChain Agent installed successfully!");
|
ui.writeInformation("SafeChain Agent installed and started successfully!");
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRunningAsAdmin() {
|
function isRunningAsAdmin() {
|
||||||
|
|
@ -89,6 +94,22 @@ function runMsiInstaller(msiPath) {
|
||||||
execSync(`msiexec /i "${msiPath}" /qn`, { stdio: "inherit" });
|
execSync(`msiexec /i "${msiPath}" /qn`, { stdio: "inherit" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopServiceIfRunning() {
|
||||||
|
try {
|
||||||
|
ui.writeInformation("Stopping existing SafeChain Agent service...");
|
||||||
|
ui.writeVerbose('Running: net stop "SafeChainAgent"');
|
||||||
|
execSync('net stop "SafeChainAgent"', { stdio: "inherit" });
|
||||||
|
} catch {
|
||||||
|
// Service is not running or doesn't exist, which is fine
|
||||||
|
ui.writeVerbose("SafeChain Agent service not running or not installed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startService() {
|
||||||
|
ui.writeVerbose('Running: net start "SafeChainAgent"');
|
||||||
|
execSync('net start "SafeChainAgent"', { stdio: "inherit" });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} msiPath
|
* @param {string} msiPath
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue