@sonde/agent 0.2.10 → 0.2.12
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/.turbo/turbo-build.log +4 -6
- package/.turbo/turbo-test.log +11 -51
- package/CHANGELOG.md +20 -0
- package/dist/cli/service.d.ts.map +1 -1
- package/dist/cli/service.js +17 -0
- package/dist/cli/service.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/connection.d.ts.map +1 -1
- package/dist/runtime/connection.js +6 -0
- package/dist/runtime/connection.js.map +1 -1
- package/dist/runtime/privilege.d.ts +1 -1
- package/dist/runtime/privilege.d.ts.map +1 -1
- package/dist/runtime/privilege.js +15 -3
- package/dist/runtime/privilege.js.map +1 -1
- package/dist/tui/installer/StepHub.d.ts.map +1 -1
- package/dist/tui/installer/StepHub.js +4 -2
- package/dist/tui/installer/StepHub.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/service.ts +18 -0
- package/src/index.ts +13 -1
- package/src/runtime/connection.ts +12 -1
- package/src/runtime/privilege.ts +14 -3
- package/src/tui/installer/StepHub.tsx +5 -2
- package/tsconfig.tsbuildinfo +1 -1
package/src/runtime/privilege.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
|
|
3
|
-
/** Exit with error if running as root (uid 0) */
|
|
3
|
+
/** Exit with error if running as root (uid 0). */
|
|
4
4
|
export function checkNotRoot(): void {
|
|
5
5
|
if (process.getuid?.() === 0) {
|
|
6
6
|
console.error('Error: sonde agent must not run as root.');
|
|
7
|
-
console.error('
|
|
8
|
-
|
|
7
|
+
console.error('');
|
|
8
|
+
if (sondeUserExists()) {
|
|
9
|
+
console.error('A "sonde" user exists. Install the systemd service:');
|
|
10
|
+
console.error(' sonde service install');
|
|
11
|
+
console.error('');
|
|
12
|
+
console.error('Or start interactively as the sonde user:');
|
|
13
|
+
console.error(' su -s /bin/sh sonde -c "sonde start"');
|
|
14
|
+
} else {
|
|
15
|
+
console.error('Create a dedicated user and re-run the installer:');
|
|
16
|
+
console.error(' useradd --system --home-dir /var/lib/sonde --create-home \\');
|
|
17
|
+
console.error(' --shell /usr/sbin/nologin sonde');
|
|
18
|
+
console.error(' sonde service install');
|
|
19
|
+
}
|
|
9
20
|
process.exit(1);
|
|
10
21
|
}
|
|
11
22
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
1
2
|
import os from 'node:os';
|
|
2
3
|
import { Box, Text, useInput } from 'ink';
|
|
3
4
|
import TextInput from 'ink-text-input';
|
|
@@ -17,11 +18,13 @@ const FIELD_LABELS: Record<Field, string> = {
|
|
|
17
18
|
agentName: 'Agent Name',
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const DEFAULT_AGENT_NAME = `${os.hostname()}-${crypto.randomBytes(3).toString('hex')}`;
|
|
22
|
+
|
|
20
23
|
export function StepHub({ onNext, initialHubUrl }: StepHubProps): JSX.Element {
|
|
21
24
|
const [activeField, setActiveField] = useState<Field>(initialHubUrl ? 'apiKey' : 'hubUrl');
|
|
22
25
|
const [hubUrl, setHubUrl] = useState(initialHubUrl ?? '');
|
|
23
26
|
const [apiKey, setApiKey] = useState('');
|
|
24
|
-
const [agentName, setAgentName] = useState(
|
|
27
|
+
const [agentName, setAgentName] = useState(DEFAULT_AGENT_NAME);
|
|
25
28
|
const [error, setError] = useState('');
|
|
26
29
|
|
|
27
30
|
const values: Record<Field, string> = { hubUrl, apiKey, agentName };
|
|
@@ -63,7 +66,7 @@ export function StepHub({ onNext, initialHubUrl }: StepHubProps): JSX.Element {
|
|
|
63
66
|
onNext({
|
|
64
67
|
hubUrl: hubUrl.trim(),
|
|
65
68
|
apiKey: apiKey.trim(),
|
|
66
|
-
agentName: agentName.trim() ||
|
|
69
|
+
agentName: agentName.trim() || DEFAULT_AGENT_NAME,
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
});
|