Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
126 lines
4.5 KiB
Bash
Executable File
126 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Reset Nginx Proxy Manager Admin Password
|
|
# This script resets the admin password in NPM database
|
|
|
|
set -e
|
|
|
|
PROXMOX_HOST="192.168.11.11"
|
|
CONTAINER_ID=105
|
|
# NEW_PASSWORD should come from argument or environment variable
|
|
NEW_PASSWORD="${1:-${NPM_PASSWORD:-}}"
|
|
if [ -z "$NEW_PASSWORD" ]; then
|
|
echo "❌ Password is required. Provide as argument or set NPM_PASSWORD in ~/.env"
|
|
echo " Usage: $0 <new-password> [email]"
|
|
exit 1
|
|
fi
|
|
EMAIL="${2:-nsatoshi2007@hotmail.com}"
|
|
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "🔐 Nginx Proxy Manager Password Reset"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo "Container: $CONTAINER_ID on $PROXMOX_HOST"
|
|
echo "New Password: $NEW_PASSWORD"
|
|
echo ""
|
|
|
|
# Check if container is running
|
|
if ! ssh root@"$PROXMOX_HOST" "pct status $CONTAINER_ID" | grep -q "running"; then
|
|
echo "❌ Container $CONTAINER_ID is not running"
|
|
exit 1
|
|
fi
|
|
|
|
echo "📋 Resetting password..."
|
|
|
|
# Reset password using NPM's built-in method
|
|
# Try to use NPM's own password hashing
|
|
echo "📋 Generating password hash using NPM's environment..."
|
|
|
|
# Method 1: Try using available bcrypt modules (bcrypt is already installed)
|
|
PASSWORD_HASH=$(ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- bash -c '
|
|
cd /app
|
|
# Try bcrypt first (already available)
|
|
node -e \"
|
|
try {
|
|
const bcrypt = require(\\\"bcrypt\\\");
|
|
console.log(bcrypt.hashSync(process.argv[1], 10));
|
|
} catch(e1) {
|
|
// Try bcryptjs if bcrypt fails
|
|
try {
|
|
const bcryptjs = require(\\\"bcryptjs\\\");
|
|
console.log(bcryptjs.hashSync(process.argv[1], 10));
|
|
} catch(e2) {
|
|
console.error(\\\"ERROR: Cannot find bcrypt or bcryptjs\\\");
|
|
process.exit(1);
|
|
}
|
|
}
|
|
\" \"$NEW_PASSWORD\"
|
|
' 2>/dev/null)
|
|
|
|
if [ -z "$PASSWORD_HASH" ] || echo "$PASSWORD_HASH" | grep -q "ERROR\|Cannot"; then
|
|
echo "⚠️ bcrypt modules not available, trying to install bcryptjs..."
|
|
echo "📦 Installing bcryptjs (this may take a minute)..."
|
|
ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- bash -c 'cd /app && timeout 120 npm install bcryptjs --no-save 2>&1'"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ bcryptjs installed successfully"
|
|
PASSWORD_HASH=$(ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- bash -c '
|
|
cd /app
|
|
node -e \"const bcrypt = require(\\\"bcryptjs\\\"); console.log(bcrypt.hashSync(process.argv[1], 10));\" \"$NEW_PASSWORD\"
|
|
' 2>/dev/null)
|
|
else
|
|
echo "❌ Failed to install bcryptjs"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$PASSWORD_HASH" ] || [ "$PASSWORD_HASH" = "null" ]; then
|
|
echo "❌ Failed to generate password hash"
|
|
echo "💡 Alternative: Access NPM web UI and use 'Forgot Password' feature"
|
|
echo " Or manually reset via: http://192.168.11.26:81"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Password hash generated"
|
|
|
|
# Update database using Node.js and better-sqlite3
|
|
echo "📝 Updating database using Node.js..."
|
|
ssh root@"$PROXMOX_HOST" "pct exec $CONTAINER_ID -- bash -c '
|
|
cd /app
|
|
npm install better-sqlite3 --no-save --silent 2>&1 | tail -3 || true
|
|
node -e \"
|
|
const Database = require(\\\"better-sqlite3\\\");
|
|
const db = new Database(\\\"/data/database.sqlite\\\");
|
|
const hash = process.argv[1];
|
|
const email = process.argv[2];
|
|
const stmt = db.prepare(\\\"UPDATE user SET password = ?, modified_on = datetime(\\\\\\\"now\\\\\\\") WHERE email = ?\\\");
|
|
const info = stmt.run(hash, email);
|
|
if (info.changes > 0) {
|
|
console.log(\\\"Password updated for \\\" + email);
|
|
} else {
|
|
// If user doesn'\''t exist, create it
|
|
const insertStmt = db.prepare(\\\"INSERT INTO user (email, name, password, is_admin, created_on, modified_on) VALUES (?, ?, ?, 1, datetime(\\\\\\\"now\\\\\\\"), datetime(\\\\\\\"now\\\\\\\"))\\\");
|
|
const insertInfo = insertStmt.run(email, email.split(\\\"@\\\")[0], hash);
|
|
if (insertInfo.changes > 0) {
|
|
console.log(\\\"User created and password set for \\\" + email);
|
|
} else {
|
|
console.error(\\\"Failed to update or create user for \\\" + email);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
db.close();
|
|
\" \"$PASSWORD_HASH\" \"$EMAIL\"
|
|
'"
|
|
|
|
echo ""
|
|
echo "✅ Password reset complete!"
|
|
echo ""
|
|
echo "New credentials:"
|
|
echo " Email: $EMAIL"
|
|
echo " Password: $NEW_PASSWORD"
|
|
echo ""
|
|
echo "Test login at: http://192.168.11.26:81"
|
|
|
|
rm -f /tmp/npm-password-hash.txt
|