Skip to content

Commit

Permalink
Use machinectl to login
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Sep 18, 2024
1 parent cbd4749 commit c20d51d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domcloud-bridge",
"version": "0.59.0",
"version": "0.60.0",
"description": "Deployment runner for DOM Cloud",
"main": "app.js",
"engines": {
Expand Down
8 changes: 3 additions & 5 deletions src/executor/runnercode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ export async function runConfigCodeFeatures(key, value, writeLog, domaindata, ss
let arg;
switch (key) {
case 'restart':
await writeLog("$> Restarting passenger processes");
await writeLog(await logmanExec.restartPassenger(domaindata));
await writeLog("$> Restarting passenger processes");
await writeLog(await logmanExec.restartPassenger(domaindata));
break;
case 'docker':
await sshExec(`export XDG_RUNTIME_DIR=/run/user/$(id -u)`, false);
await sshExec(`export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock`, false);
await sshExec(`export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus`, false);
if (value === '' || value === 'on') {
await writeLog("$> Enabling docker features");
await writeLog(await dockerExec.enableDocker(domaindata['Username']));
await sshExec(`sed -i '/DOCKER_HOST=/d' ~/.bashrc`, false);
await sshExec(`echo "export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock" >> ~/.bashrc;`);
await sshExec(`mkdir -p ~/.config/docker; echo '{"exec-opts": ["native.cgroupdriver=cgroupfs"]}' > ~/.config/docker/daemon.json`);
await sshExec(`dockerd-rootless-setuptool.sh install`);
await sshExec(`export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock`, false);
} else if (value === 'off') {
await writeLog("$> Disabling docker features");
await sshExec(`dockerd-rootless-setuptool.sh uninstall`);
Expand Down
16 changes: 3 additions & 13 deletions src/executor/runnersub.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
if (config.source || config.commands || config.services) {
await sshExec(`shopt -s dotglob`, false);
await sshExec(`export DOMAIN='${subdomain}'`, false);
// enable managing systemd for linger user
await sshExec(`export XDG_RUNTIME_DIR=/run/user/$(id -u)`, false);
await sshExec(`export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus`, false);
await sshExec(`mkdir -p ${subdomaindata['Home directory']}/public_html && cd "$_"`);
}

Expand Down Expand Up @@ -470,22 +467,15 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
}

if (config.services) {
const addFlags = typeof config.services == 'string' ? `-f ${config.services} --progress quiet` : '--progress quiet';
await writeLog("$> Removing docker compose services if exists");
if (typeof config.services == 'string') {
await sshExec(`docker compose -f ${config.services} --progress quiet down --remove-orphans --rmi all || true`);
} else {
await sshExec(`docker compose --progress-plain quiet --remove-orphans --rmi all || true`);
}
await sshExec(`docker compose ${addFlags} down --remove-orphans --rmi all || true`);
await writeLog("$> Configuring NGINX forwarding for docker");
let d = await dockerExec.executeServices(config.services, subdomaindata['Home directory'] + '/public_html', subdomain, writeLog);
await writeLog("$> Writing docker compose services");
await writeLog(d.split('\n').map(x => ` ${x}`).join('\n'));
await writeLog("$> Applying compose services");
if (typeof config.services == 'string') {
await sshExec(`docker compose -f ${config.services} --progress quiet up --build --detach`);
} else {
await sshExec(`docker compose up --build --detach`);
}
await sshExec(`docker compose ${addFlags} up --build --detach`);
await sshExec(`docker ps`);
}

Expand Down
2 changes: 1 addition & 1 deletion sudoutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ switch (cli.args.shift()) {
break;
case 'SHELL_INTERACTIVE':
arg = cli.args.shift();
var su = spawn(env.BASH_SU, [arg, '-s', env.BASH_PATH, '-P', '-l'], {
var su = spawn("machinectl", ['-q', 'shell', arg + '@'], {
stdio: 'inherit'
});
su.on('close', function (code) {
Expand Down

0 comments on commit c20d51d

Please sign in to comment.