diff --git a/backend/mpc-system/scripts/deploy.sh b/backend/mpc-system/scripts/deploy.sh index 628ed204..a6b8fd57 100644 --- a/backend/mpc-system/scripts/deploy.sh +++ b/backend/mpc-system/scripts/deploy.sh @@ -444,21 +444,27 @@ regenerate_keys() { local JWT_SECRET=$(generate_random_password) local API_KEY=$(generate_random_password) - # Update only the keys that might have placeholder values if [ -f "$CONFIG_DIR/mpc.env" ]; then - # Replace placeholder master key patterns - sed -i "s/your_64_hex_characters_master_key_here/${MASTER_KEY}/g" "$CONFIG_DIR/mpc.env" - sed -i "s/0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef/${MASTER_KEY}/g" "$CONFIG_DIR/mpc.env" + # Replace CRYPTO_MASTER_KEY and MPC_CRYPTO_MASTER_KEY lines entirely + # This handles any existing value, not just specific placeholders + sed -i "s/^CRYPTO_MASTER_KEY=.*/CRYPTO_MASTER_KEY=${MASTER_KEY}/" "$CONFIG_DIR/mpc.env" + sed -i "s/^MPC_CRYPTO_MASTER_KEY=.*/MPC_CRYPTO_MASTER_KEY=${MASTER_KEY}/" "$CONFIG_DIR/mpc.env" - # Replace placeholder JWT key - sed -i "s/your_super_secure_jwt_secret_key_at_least_32_characters/${JWT_SECRET}/g" "$CONFIG_DIR/mpc.env" + # Replace JWT keys + sed -i "s/^JWT_SECRET_KEY=.*/JWT_SECRET_KEY=${JWT_SECRET}/" "$CONFIG_DIR/mpc.env" + sed -i "s/^MPC_JWT_SECRET_KEY=.*/MPC_JWT_SECRET_KEY=${JWT_SECRET}/" "$CONFIG_DIR/mpc.env" - # Replace placeholder API key - sed -i "s/your_very_secure_api_key_at_least_32_characters/${API_KEY}/g" "$CONFIG_DIR/mpc.env" + # Replace API key + sed -i "s/^MPC_API_KEY=.*/MPC_API_KEY=${API_KEY}/" "$CONFIG_DIR/mpc.env" log_info "Keys regenerated successfully" - log_info "New MASTER_KEY: ${MASTER_KEY:0:16}... (hidden)" - log_info "Restart services with: $0 restart" + log_info "New MASTER_KEY: ${MASTER_KEY:0:16}..." + log_info "New JWT_SECRET: ${JWT_SECRET:0:8}..." + log_info "New API_KEY: ${API_KEY:0:8}..." + log_info "" + log_info "Now reconfigure PostgreSQL with new password and restart services:" + log_info " $0 reconfigure" + log_info " $0 restart" else log_error "Environment file not found: $CONFIG_DIR/mpc.env" exit 1