refactor: fmt
This commit is contained in:
parent
c28429de2f
commit
09ee1d3507
@ -5,41 +5,46 @@ const Either = require('fp-ts/Either')
|
||||
const Cmd = require('../cmd.js')
|
||||
const LinuxUser = require('./linux-user.js')
|
||||
|
||||
const dockerCompose = cfg => yaml.stringify({
|
||||
services: {
|
||||
db: {
|
||||
image: 'postgres:15.3',
|
||||
// restart: always will start the container on system startup / reboot if
|
||||
// docker.service enabled (see ./linux-user.js)
|
||||
restart: 'always',
|
||||
volumes: [`${cfg.postgres.dataDir}:/var/lib/postgres/data`],
|
||||
ports: [`${cfg.network.interfaceIp}:${cfg.network.port}:5432`],
|
||||
environment: {
|
||||
POSTGRES_USER: cfg.postgres.username,
|
||||
POSTGRES_PASSWORD: cfg.postgres.password,
|
||||
const dockerCompose = cfg =>
|
||||
yaml.stringify({
|
||||
services: {
|
||||
db: {
|
||||
image: 'postgres:15.3',
|
||||
// restart: always will start the container on system startup / reboot if
|
||||
// docker.service enabled (see ./linux-user.js)
|
||||
restart: 'always',
|
||||
volumes: [`${cfg.postgres.dataDir}:/var/lib/postgres/data`],
|
||||
ports: [`${cfg.network.interfaceIp}:${cfg.network.port}:5432`],
|
||||
environment: {
|
||||
POSTGRES_USER: cfg.postgres.username,
|
||||
POSTGRES_PASSWORD: cfg.postgres.password,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
const steps = cfg => [
|
||||
LinuxUser.step(cfg),
|
||||
{
|
||||
up: {
|
||||
label: `${cfg.linuxUser.username}: create db on ${cfg.network.interfaceIp}:${cfg.network.port}`,
|
||||
work: (a) => pipe(
|
||||
Cmd.doas(cfg.linuxUser.username, [
|
||||
'set -x',
|
||||
'cat << "EOCOMPOSE" > ~/docker-compose.yaml',
|
||||
dockerCompose(cfg),
|
||||
'EOCOMPOSE',
|
||||
'docker compose up -d',
|
||||
].join('\n')),
|
||||
Either.map(() => a),
|
||||
),
|
||||
work: a =>
|
||||
pipe(
|
||||
Cmd.doas(
|
||||
cfg.linuxUser.username,
|
||||
[
|
||||
'set -x',
|
||||
'cat << "EOCOMPOSE" > ~/docker-compose.yaml',
|
||||
dockerCompose(cfg),
|
||||
'EOCOMPOSE',
|
||||
'docker compose up -d',
|
||||
].join('\n'),
|
||||
),
|
||||
Either.map(() => a),
|
||||
),
|
||||
},
|
||||
// down handled by LinuxUser killing user processes
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
module.exports = { steps }
|
||||
|
@ -94,9 +94,12 @@ const statePersisted = cfg =>
|
||||
),
|
||||
)
|
||||
|
||||
const userDeleted = cfg => pipe(
|
||||
Cmd.run(`until userdel ${cfg.linuxUser.username}; do pkill -eU ${cfg.linuxUser.username} || true; done;`),
|
||||
Either.flatMap(() => Cmd.run(`rm -r ${cfg.linuxUser.homeDir} || true`)),
|
||||
const userDeleted = cfg =>
|
||||
pipe(
|
||||
Cmd.run(
|
||||
`until userdel ${cfg.linuxUser.username}; do pkill -eU ${cfg.linuxUser.username} || true; done;`,
|
||||
),
|
||||
Either.flatMap(() => Cmd.run(`rm -r ${cfg.linuxUser.homeDir} || true`)),
|
||||
)
|
||||
|
||||
const step = cfg => ({
|
||||
|
Loading…
Reference in New Issue
Block a user