jetcheck 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +4 -4
- package/bin/run.js +3 -12
- package/bin/systemd.js +11 -11
- package/index.js +2 -7
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -5,15 +5,15 @@ const sc = require('subcommander');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const crypto = require('crypto');
|
|
8
|
-
const
|
|
8
|
+
const jetcheck = require("../index")
|
|
9
9
|
|
|
10
10
|
// Early loading configuration file
|
|
11
11
|
const configFile = path.resolve(
|
|
12
12
|
process.cwd(),
|
|
13
|
-
process.env.CONFIG || `${os.homedir()}/.
|
|
13
|
+
process.env.CONFIG || `${os.homedir()}/.jetcheck/config.js`
|
|
14
14
|
)
|
|
15
|
-
require("./systemd")(
|
|
16
|
-
require("./run")(
|
|
15
|
+
require("./systemd")(jetcheck, sc, configFile)
|
|
16
|
+
require("./run")(jetcheck, sc, configFile)
|
|
17
17
|
|
|
18
18
|
sc.parse()
|
|
19
19
|
|
package/bin/run.js
CHANGED
|
@@ -3,23 +3,14 @@
|
|
|
3
3
|
const fs = require('fs')
|
|
4
4
|
const path = require("path")
|
|
5
5
|
|
|
6
|
-
module.exports = (
|
|
6
|
+
module.exports = (jetcheck, sc, configFile) => {
|
|
7
7
|
sc.command('run', {
|
|
8
|
-
desc: 'Run the
|
|
8
|
+
desc: 'Run the check',
|
|
9
9
|
callback: async function (options) {
|
|
10
|
-
const kernel = new
|
|
10
|
+
const kernel = new jetcheck({ configFile })
|
|
11
11
|
await kernel.start()
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
|
-
|
|
15
|
-
sc.command('test', {
|
|
16
|
-
desc: 'Run the monitoring',
|
|
17
|
-
callback: async function (options) {
|
|
18
|
-
const kernel = new netcheck({ headless: true, configFile })
|
|
19
|
-
await kernel.start()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
})
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
|
package/bin/systemd.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs')
|
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const ejs = require("ejs")
|
|
6
6
|
|
|
7
|
-
module.exports = (
|
|
7
|
+
module.exports = (jetcheck, sc, configFile) => {
|
|
8
8
|
|
|
9
9
|
const systemd = sc.command('systemd', {
|
|
10
10
|
desc: 'Linux systemd service management'
|
|
@@ -15,7 +15,7 @@ module.exports = (netcheck, sc, configFile) => {
|
|
|
15
15
|
callback: async function (options) {
|
|
16
16
|
var installed = false
|
|
17
17
|
try {
|
|
18
|
-
fs.statSync("/etc/systemd/system/
|
|
18
|
+
fs.statSync("/etc/systemd/system/jetcheck.service")
|
|
19
19
|
installed = true
|
|
20
20
|
} catch (e) { }
|
|
21
21
|
|
|
@@ -24,16 +24,16 @@ module.exports = (netcheck, sc, configFile) => {
|
|
|
24
24
|
process.exit(-1)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const kernel = new
|
|
27
|
+
const kernel = new jetcheck({ configFile })
|
|
28
28
|
|
|
29
29
|
const runCmd = `${process.argv[0]} ${process.argv[1]} run`
|
|
30
30
|
const content = fs.readFileSync(__dirname + "/systemd.conf").toString()
|
|
31
31
|
const render = ejs.render(content, { configFile, runCmd, cwd: process.cwd(), config: `CONFIG=${configFile}` })
|
|
32
|
-
fs.writeFileSync("/etc/systemd/system/
|
|
32
|
+
fs.writeFileSync("/etc/systemd/system/jetcheck.service", render)
|
|
33
33
|
|
|
34
34
|
await kernel.lib.exec("systemctl daemon-reload", false)
|
|
35
|
-
await kernel.lib.exec("systemctl enable
|
|
36
|
-
console.log("To start type: systemctl start
|
|
35
|
+
await kernel.lib.exec("systemctl enable jetcheck", false)
|
|
36
|
+
console.log("To start type: systemctl start jetcheck")
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ module.exports = (netcheck, sc, configFile) => {
|
|
|
42
42
|
callback: async function (options) {
|
|
43
43
|
var installed = false
|
|
44
44
|
try {
|
|
45
|
-
fs.statSync("/etc/systemd/system/
|
|
45
|
+
fs.statSync("/etc/systemd/system/jetcheck.service")
|
|
46
46
|
installed = true
|
|
47
47
|
} catch (e) { }
|
|
48
48
|
|
|
@@ -50,11 +50,11 @@ module.exports = (netcheck, sc, configFile) => {
|
|
|
50
50
|
console.log("Netcheck is not installed")
|
|
51
51
|
process.exit(-1)
|
|
52
52
|
}
|
|
53
|
-
const kernel = new
|
|
53
|
+
const kernel = new jetcheck({ configFile })
|
|
54
54
|
|
|
55
|
-
await kernel.lib.exec("systemctl stop
|
|
56
|
-
await kernel.lib.exec("systemctl disable
|
|
57
|
-
fs.unlinkSync("/etc/systemd/system/
|
|
55
|
+
await kernel.lib.exec("systemctl stop jetcheck", false)
|
|
56
|
+
await kernel.lib.exec("systemctl disable jetcheck", false)
|
|
57
|
+
fs.unlinkSync("/etc/systemd/system/jetcheck.service")
|
|
58
58
|
await kernel.lib.exec("systemctl daemon-reload", false)
|
|
59
59
|
console.log("Netcheck deinstalled")
|
|
60
60
|
}
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const path = require("path")
|
|
|
4
4
|
const pack = require("./package.json")
|
|
5
5
|
const aevent = require("./lib/aevent")
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class jetcheck {
|
|
8
8
|
constructor(options) {
|
|
9
9
|
this.options = options || {}
|
|
10
10
|
this.events = new aevent()
|
|
@@ -60,13 +60,8 @@ class netcheck {
|
|
|
60
60
|
|
|
61
61
|
await this.events.emit("kernel.init", this)
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
async stop() {
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
module.exports =
|
|
65
|
+
module.exports = jetcheck
|
|
71
66
|
|
|
72
67
|
|