fix: remove auto-init of pass_mgr from install script
- Remove automatic pass_mgr admin init during installation - Users must manually run 'pass_mgr admin init' after install - Update install summary to show initialization as a required step - This allows non-interactive installation
This commit is contained in:
77
install.mjs
77
install.mjs
@@ -388,15 +388,25 @@ function copyModule(source, dest) {
|
|||||||
|
|
||||||
if (!existsSync(srcPath)) continue;
|
if (!existsSync(srcPath)) continue;
|
||||||
|
|
||||||
const stat = execSync(`stat -c %F "${srcPath}" 2>/dev/null || echo "file"`, {
|
try {
|
||||||
silent: true,
|
const stat = execSync(`stat -c %F "${srcPath}" 2>/dev/null || echo "file"`, {
|
||||||
cwd: __dirname
|
encoding: 'utf8',
|
||||||
}).trim();
|
cwd: __dirname
|
||||||
|
}).trim();
|
||||||
if (stat === 'directory') {
|
|
||||||
exec(`cp -r "${srcPath}" "${destPath}"`, { silent: true });
|
if (stat === 'directory') {
|
||||||
} else {
|
execSync(`cp -r "${srcPath}" "${destPath}"`, { cwd: __dirname });
|
||||||
copyFileSync(srcPath, destPath);
|
} else {
|
||||||
|
copyFileSync(srcPath, destPath);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
// Fallback: try to copy as file first, then directory
|
||||||
|
try {
|
||||||
|
copyFileSync(srcPath, destPath);
|
||||||
|
} catch {
|
||||||
|
// If file copy fails, try directory copy
|
||||||
|
execSync(`cp -r "${srcPath}" "${destPath}"`, { cwd: __dirname });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -422,45 +432,10 @@ async function configure(env) {
|
|||||||
const configPath = join(adminKeyDir, 'config.json');
|
const configPath = join(adminKeyDir, 'config.json');
|
||||||
|
|
||||||
if (existsSync(configPath)) {
|
if (existsSync(configPath)) {
|
||||||
logWarning('pass_mgr already initialized');
|
logSuccess('pass_mgr already initialized');
|
||||||
const reinit = await prompt(' Reinitialize? (y/N): ');
|
} else {
|
||||||
if (reinit.toLowerCase() !== 'y') {
|
log(' pass_mgr not initialized yet.', 'yellow');
|
||||||
log(' Skipping initialization');
|
log(' Run "pass_mgr admin init" manually after installation.', 'cyan');
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize pass_mgr
|
|
||||||
log(' Initializing pass_mgr...', 'blue');
|
|
||||||
log(' Please set your admin password for pass_mgr.', 'yellow');
|
|
||||||
|
|
||||||
const adminPassword = await promptPassword(' Admin password: ');
|
|
||||||
if (!adminPassword) {
|
|
||||||
logWarning('Empty password, skipping initialization');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmPassword = await promptPassword(' Confirm password: ');
|
|
||||||
if (adminPassword !== confirmPassword) {
|
|
||||||
logError('Passwords do not match');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Write password to temp file and init
|
|
||||||
const tempKeyFile = join(adminKeyDir, '.tmp_key');
|
|
||||||
mkdirSync(adminKeyDir, { recursive: true, mode: 0o700 });
|
|
||||||
writeFileSync(tempKeyFile, adminPassword, { mode: 0o600 });
|
|
||||||
|
|
||||||
exec(`${passMgrPath} admin init --key-path "${tempKeyFile}"`, { silent: !options.verbose });
|
|
||||||
|
|
||||||
// Remove temp file
|
|
||||||
execSync(`rm -f "${tempKeyFile}"`);
|
|
||||||
|
|
||||||
logSuccess('pass_mgr initialized successfully');
|
|
||||||
} catch (err) {
|
|
||||||
logError(`Failed to initialize pass_mgr: ${err.message}`);
|
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create environment config
|
// Create environment config
|
||||||
@@ -578,8 +553,10 @@ function printSummary(env) {
|
|||||||
log('2. Reload your shell or run:', 'yellow');
|
log('2. Reload your shell or run:', 'yellow');
|
||||||
log(` source ${join(installDir, 'paddedcell.env')}`, 'cyan');
|
log(` source ${join(installDir, 'paddedcell.env')}`, 'cyan');
|
||||||
console.log('');
|
console.log('');
|
||||||
log('3. Test pass_mgr:', 'yellow');
|
log('3. Initialize pass_mgr (required before first use):', 'yellow');
|
||||||
log(' pass_mgr admin init # Initialize (if not done)', 'cyan');
|
log(' pass_mgr admin init', 'cyan');
|
||||||
|
console.log('');
|
||||||
|
log('4. Test pass_mgr:', 'yellow');
|
||||||
log(' pass_mgr set test_key mypass # Set a test password', 'cyan');
|
log(' pass_mgr set test_key mypass # Set a test password', 'cyan');
|
||||||
log(' pass_mgr get test_key # Retrieve password', 'cyan');
|
log(' pass_mgr get test_key # Retrieve password', 'cyan');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user