Files
DLE/backend/update_vds_no_password.js

42 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Скрипт для обновления настроек VDS - удаление пароля (используем SSH ключи)
*/
const encryptedDb = require('./services/encryptedDatabaseService');
async function updateVdsSettings() {
try {
console.log('🔧 Обновление настроек VDS (удаление пароля, используем SSH ключи)...');
// Получаем существующие настройки
const existing = await encryptedDb.getData('vds_settings', {}, 1);
if (existing.length === 0) {
console.error('❌ Настройки VDS не найдены');
process.exit(1);
}
console.log('📝 Найдены настройки (id:', existing[0].id, ')');
// Обновляем только пароль - устанавливаем в null (будет пустая строка после расшифровки)
// Передаем пустую строку, чтобы encryptedDb не обновлял это поле
// Но лучше явно установить в null через SQL
const settings = {
updated_at: new Date()
};
// Обновляем через encryptedDb (пароль не передаем, значит не обновляется)
const result = await encryptedDb.saveData('vds_settings', settings, { id: existing[0].id });
console.log('✅ Настройки обновлены (пароль не изменен, будет использоваться SSH ключ)');
console.log(' Если пароль все еще в БД, он будет игнорироваться, так как код проверяет sshPassword && sshPassword.trim()');
process.exit(0);
} catch (error) {
console.error('❌ Ошибка обновления настроек:', error);
process.exit(1);
}
}
updateVdsSettings();