From 5084cfecb81ee6ccac9b6cec0899dbf1e8212799 Mon Sep 17 00:00:00 2001 From: zhi Date: Thu, 5 Mar 2026 10:28:13 +0000 Subject: [PATCH] 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 --- install.mjs | 77 +++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/install.mjs b/install.mjs index 4b64a4d..8700b99 100755 --- a/install.mjs +++ b/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(); - - if (stat === 'directory') { - exec(`cp -r "${srcPath}" "${destPath}"`, { silent: true }); - } else { - copyFileSync(srcPath, destPath); + try { + const stat = execSync(`stat -c %F "${srcPath}" 2>/dev/null || echo "file"`, { + encoding: 'utf8', + cwd: __dirname + }).trim(); + + 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'); }