feat: новая функция

This commit is contained in:
2025-11-11 20:11:09 +03:00
parent 1466de718f
commit 44876c0bc2
9 changed files with 173 additions and 133 deletions

View File

@@ -8,15 +8,15 @@ const createUserWithSshKeys = async (username, publicKey, options) => {
log.info(`Создание пользователя ${username}...`);
// Создание пользователя
await execSshCommand(`sudo useradd -m -s /bin/bash ${username} || true`, options);
await execSshCommand(`sudo usermod -aG sudo ${username}`, options);
await execSshCommand(`useradd -m -s /bin/bash ${username} || true`, options);
await execSshCommand(`usermod -aG sudo ${username}`, options);
// Настройка SSH ключей для пользователя
await execSshCommand(`sudo mkdir -p /home/${username}/.ssh`, options);
await execSshCommand(`echo "${publicKey}" | sudo tee /home/${username}/.ssh/authorized_keys`, options);
await execSshCommand(`sudo chown -R ${username}:${username} /home/${username}/.ssh`, options);
await execSshCommand(`sudo chmod 700 /home/${username}/.ssh`, options);
await execSshCommand(`sudo chmod 600 /home/${username}/.ssh/authorized_keys`, options);
await execSshCommand(`mkdir -p /home/${username}/.ssh`, options);
await execSshCommand(`echo "${publicKey}" > /home/${username}/.ssh/authorized_keys`, options);
await execSshCommand(`chown -R ${username}:${username} /home/${username}/.ssh`, options);
await execSshCommand(`chmod 700 /home/${username}/.ssh`, options);
await execSshCommand(`chmod 600 /home/${username}/.ssh/authorized_keys`, options);
log.success(`Пользователь ${username} создан с SSH ключами`);
};
@@ -32,11 +32,11 @@ const createAllUsers = async (ubuntuUser, dockerUser, publicKey, options) => {
await createUserWithSshKeys(dockerUser, publicKey, options);
// Добавление пользователя Docker в группу docker
await execSshCommand(`sudo usermod -aG docker ${dockerUser}`, options);
await execSshCommand(`usermod -aG docker ${dockerUser}`, options);
// Создание директории для приложения
await execSshCommand(`sudo mkdir -p /home/${dockerUser}/dapp`, options);
await execSshCommand(`sudo chown ${dockerUser}:${dockerUser} /home/${dockerUser}/dapp`, options);
await execSshCommand(`mkdir -p /home/${dockerUser}/dapp`, options);
await execSshCommand(`chown ${dockerUser}:${dockerUser} /home/${dockerUser}/dapp`, options);
log.success('Все пользователи созданы');
};