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:
75
install.mjs
75
install.mjs
@@ -388,15 +388,25 @@ function copyModule(source, dest) {
|
||||
|
||||
if (!existsSync(srcPath)) continue;
|
||||
|
||||
const stat = execSync(`stat -c %F "${srcPath}" 2>/dev/null || echo "file"`, {
|
||||
silent: true,
|
||||
cwd: __dirname
|
||||
}).trim();
|
||||
try {
|
||||
const stat = execSync(`stat -c %F "${srcPath}" 2>/dev/null || echo "file"`, {
|
||||
encoding: 'utf8',
|
||||
cwd: __dirname
|
||||
}).trim();
|
||||
|
||||
if (stat === 'directory') {
|
||||
exec(`cp -r "${srcPath}" "${destPath}"`, { silent: true });
|
||||
} else {
|
||||
copyFileSync(srcPath, destPath);
|
||||
if (stat === 'directory') {
|
||||
execSync(`cp -r "${srcPath}" "${destPath}"`, { cwd: __dirname });
|
||||
} 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');
|
||||
|
||||
if (existsSync(configPath)) {
|
||||
logWarning('pass_mgr already initialized');
|
||||
const reinit = await prompt(' Reinitialize? (y/N): ');
|
||||
if (reinit.toLowerCase() !== 'y') {
|
||||
log(' Skipping initialization');
|
||||
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;
|
||||
logSuccess('pass_mgr already initialized');
|
||||
} else {
|
||||
log(' pass_mgr not initialized yet.', 'yellow');
|
||||
log(' Run "pass_mgr admin init" manually after installation.', 'cyan');
|
||||
}
|
||||
|
||||
// Create environment config
|
||||
@@ -578,8 +553,10 @@ function printSummary(env) {
|
||||
log('2. Reload your shell or run:', 'yellow');
|
||||
log(` source ${join(installDir, 'paddedcell.env')}`, 'cyan');
|
||||
console.log('');
|
||||
log('3. Test pass_mgr:', 'yellow');
|
||||
log(' pass_mgr admin init # Initialize (if not done)', 'cyan');
|
||||
log('3. Initialize pass_mgr (required before first use):', 'yellow');
|
||||
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 get test_key # Retrieve password', 'cyan');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user