Add support for running routines via command line
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
const State = require('../State')
|
||||
|
||||
class CommandState extends State {
|
||||
#ran_once = false
|
||||
|
||||
static get services() {
|
||||
return [...super.services, 'output']
|
||||
}
|
||||
|
||||
async apply() {
|
||||
const cmd = `${this._config.cmd}`
|
||||
await this._host.run(cmd)
|
||||
const result = await this._host.run(cmd)
|
||||
this.#ran_once = true
|
||||
}
|
||||
|
||||
async check() {
|
||||
return false
|
||||
return this.#ran_once
|
||||
}
|
||||
|
||||
async reverse() {
|
||||
@@ -30,6 +33,10 @@ class CommandState extends State {
|
||||
check_message() {
|
||||
return `The command check was not successful.`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Run the command: ${this._config.cmd}`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = CommandState
|
||||
|
||||
@@ -20,6 +20,10 @@ class IsAliveState extends State {
|
||||
check_message() {
|
||||
return this.failure_message()
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the host is alive...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = IsAliveState
|
||||
|
||||
@@ -27,6 +27,10 @@ class PackageAbsentState extends State {
|
||||
check_message() {
|
||||
return this.failure_message()
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the package ${this._config.package} is not installed...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = PackageAbsentState
|
||||
|
||||
@@ -31,6 +31,10 @@ class PackageCacheClearedState extends State {
|
||||
check_message() {
|
||||
return `The package cache on host "${this._host.name}" has not been cleared.`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the package cache is cleared...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = PackageCacheClearedState
|
||||
|
||||
@@ -27,6 +27,10 @@ class PackageState extends State {
|
||||
check_message() {
|
||||
return this.failure_message()
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the package ${this._config.package} is installed...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = PackageState
|
||||
|
||||
@@ -31,6 +31,10 @@ class ServiceDaemonReloadState extends State {
|
||||
check_message() {
|
||||
return `The service daemon on host "${this._host.name}" has not been reloaded.`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Reload the service daemon...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = ServiceDaemonReloadState
|
||||
|
||||
@@ -32,6 +32,10 @@ class ServiceRestartState extends State {
|
||||
check_message() {
|
||||
return `The service "${this._config.service}" on host "${this._host.name}" has not been restarted.`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Restart the ${this._config.service} service...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = ServiceRestartState
|
||||
|
||||
@@ -33,6 +33,10 @@ class ServiceState extends State {
|
||||
check_message() {
|
||||
return this.failure_message()
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the ${this._config.service} service is running...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = ServiceState
|
||||
|
||||
@@ -32,6 +32,10 @@ class ServiceStoppedState extends State {
|
||||
check_message() {
|
||||
return `The service "${this._config.service}" on host "${this._host.name}" has not been stopped.`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that the ${this._config.service} service is not running...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = ServiceStoppedState
|
||||
|
||||
@@ -32,6 +32,10 @@ class UpdateState extends State {
|
||||
check_message() {
|
||||
return `There are package updates pending on the host "${this._host.name}."`
|
||||
}
|
||||
|
||||
display() {
|
||||
return `Ensure that all packages are up to date...`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = UpdateState
|
||||
|
||||
Reference in New Issue
Block a user