herdr-remote 0.2.23 → 0.2.24
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/dist/i18n/en.js +2 -2
- package/dist/i18n/zh.js +2 -2
- package/dist/keepalive/windows-service-setup.js +27 -18
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
package/dist/i18n/en.js
CHANGED
|
@@ -134,8 +134,8 @@ const en = {
|
|
|
134
134
|
'keepalive.serviceNote': 'Runs as a Windows service under your account and starts at boot, before anyone signs in. Installing or removing it asks for administrator rights.',
|
|
135
135
|
'keepalive.serviceWindowHint': 'Finish the installation in the administrator window that opens.',
|
|
136
136
|
'keepalive.elevationCancelled': 'Administrator rights were not granted; nothing was installed.',
|
|
137
|
-
'keepalive.passwordPrompt': 'Windows password for {account} (
|
|
138
|
-
'keepalive.passwordRejected': 'Windows
|
|
137
|
+
'keepalive.passwordPrompt': 'Windows account password for {account} (not a PIN; press Enter if there is no password):',
|
|
138
|
+
'keepalive.passwordRejected': 'Windows could not start the service with those credentials. Check the account password and service logon policy.',
|
|
139
139
|
'keepalive.serviceInstalled': 'Service {id} is installed and running.',
|
|
140
140
|
'keepalive.wrongAccount': 'Run this as the account that will use herdr-remote, not another administrator account.',
|
|
141
141
|
'keepalive.pressEnter': 'Press Enter to close this window.',
|
package/dist/i18n/zh.js
CHANGED
|
@@ -133,8 +133,8 @@ const zh = {
|
|
|
133
133
|
'keepalive.serviceNote': '以你的账户作为 Windows 服务运行,开机后、登录前自动启动。安装或移除需要管理员权限。',
|
|
134
134
|
'keepalive.serviceWindowHint': '请在随后打开的管理员窗口中完成安装。',
|
|
135
135
|
'keepalive.elevationCancelled': '未授予管理员权限,未安装服务。',
|
|
136
|
-
'keepalive.passwordPrompt': '请输入 {account} 的 Windows
|
|
137
|
-
'keepalive.passwordRejected': 'Windows
|
|
136
|
+
'keepalive.passwordPrompt': '请输入 {account} 的 Windows 账户密码(不是 PIN;账户无密码时直接按 Enter):',
|
|
137
|
+
'keepalive.passwordRejected': 'Windows 未能使用这些凭据启动服务。请检查账户密码和“作为服务登录”策略。',
|
|
138
138
|
'keepalive.serviceInstalled': '服务 {id} 已安装并正在运行。',
|
|
139
139
|
'keepalive.wrongAccount': '请使用将运行 herdr-remote 的账户执行此操作,不要换用其他管理员账户。',
|
|
140
140
|
'keepalive.pressEnter': '按 Enter 关闭此窗口。',
|
|
@@ -59,6 +59,30 @@ function failure(label, result) {
|
|
|
59
59
|
const output = String(result.stdout || result.stderr || '').trim();
|
|
60
60
|
return new Error(`${label} failed (${String(result.status)}): ${output}`);
|
|
61
61
|
}
|
|
62
|
+
export async function configureAndStartServiceAccount(id, account, t, dependencies = {}) {
|
|
63
|
+
const setAccount = dependencies.setAccount || setServiceAccount;
|
|
64
|
+
const start = dependencies.start || startService;
|
|
65
|
+
const prompt = dependencies.prompt ||
|
|
66
|
+
((name) => promptSecret(t('keepalive.passwordPrompt', { account: name })));
|
|
67
|
+
const write = dependencies.write || ((message) => process.stdout.write(message));
|
|
68
|
+
for (let attempt = 0; attempt <= MAX_PASSWORD_ATTEMPTS; attempt += 1) {
|
|
69
|
+
const password = attempt === 0 ? '' : await prompt(account);
|
|
70
|
+
if (password === null)
|
|
71
|
+
return false;
|
|
72
|
+
const changed = setAccount(id, account, password);
|
|
73
|
+
if (changed.error || changed.status !== 0)
|
|
74
|
+
throw failure('Setting the Windows service account', changed);
|
|
75
|
+
const started = classifyStartResult(start());
|
|
76
|
+
if (started === 'ok')
|
|
77
|
+
return true;
|
|
78
|
+
if (started !== 'logon-failed') {
|
|
79
|
+
write(`${started.message}\n`);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
write(`${t('keepalive.passwordRejected')}\n`);
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
62
86
|
/** Complete service installation inside the elevated console. */
|
|
63
87
|
export async function completeServiceInstall(t) {
|
|
64
88
|
try {
|
|
@@ -87,24 +111,9 @@ export async function completeServiceInstall(t) {
|
|
|
87
111
|
throw failure('WinSW install', installed);
|
|
88
112
|
const { domain, user } = currentServiceAccount();
|
|
89
113
|
const account = `${domain}\\${user}`;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return 1;
|
|
94
|
-
const changed = setServiceAccount(paths.id, account, password);
|
|
95
|
-
if (changed.error || changed.status !== 0)
|
|
96
|
-
throw failure('Setting the Windows service account', changed);
|
|
97
|
-
const started = classifyStartResult(startService());
|
|
98
|
-
if (started === 'ok') {
|
|
99
|
-
process.stdout.write(`${t('keepalive.serviceInstalled', { id: paths.id })}\n`);
|
|
100
|
-
return 0;
|
|
101
|
-
}
|
|
102
|
-
if (started === 'logon-failed') {
|
|
103
|
-
process.stdout.write(`${t('keepalive.passwordRejected')}\n`);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
process.stdout.write(`${started.message}\n`);
|
|
107
|
-
return 1;
|
|
114
|
+
if (await configureAndStartServiceAccount(paths.id, account, t)) {
|
|
115
|
+
process.stdout.write(`${t('keepalive.serviceInstalled', { id: paths.id })}\n`);
|
|
116
|
+
return 0;
|
|
108
117
|
}
|
|
109
118
|
return 1;
|
|
110
119
|
}
|
package/herdr-plugin.toml
CHANGED