feat: rde
This commit is contained in:
parent
7795c524f0
commit
4df32a9bc0
@ -494,7 +494,6 @@ export async function createRemoteEngineConfiguration(id: string) {
|
|||||||
export async function executeDockerCmd({ dockerId, command }: { dockerId: string, command: string }) {
|
export async function executeDockerCmd({ dockerId, command }: { dockerId: string, command: string }) {
|
||||||
let { remoteEngine, remoteIpAddress, remoteUser, engine } = await prisma.destinationDocker.findUnique({ where: { id: dockerId } })
|
let { remoteEngine, remoteIpAddress, remoteUser, engine } = await prisma.destinationDocker.findUnique({ where: { id: dockerId } })
|
||||||
if (remoteEngine) engine = `ssh://${remoteUser}@${remoteIpAddress}`
|
if (remoteEngine) engine = `ssh://${remoteUser}@${remoteIpAddress}`
|
||||||
|
|
||||||
const host = getEngine(engine)
|
const host = getEngine(engine)
|
||||||
if (engine.startsWith('ssh://')) {
|
if (engine.startsWith('ssh://')) {
|
||||||
await createRemoteEngineConfiguration(dockerId)
|
await createRemoteEngineConfiguration(dockerId)
|
||||||
@ -953,36 +952,44 @@ export async function updatePasswordInDb(database, user, newPassword, isRoot) {
|
|||||||
dbUserPassword,
|
dbUserPassword,
|
||||||
defaultDatabase,
|
defaultDatabase,
|
||||||
destinationDockerId,
|
destinationDockerId,
|
||||||
destinationDocker: { engine }
|
destinationDocker: { id: dockerId }
|
||||||
} = database;
|
} = database;
|
||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
const host = getEngine(engine);
|
|
||||||
if (type === 'mysql') {
|
if (type === 'mysql') {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"ALTER USER '${user}'@'%' IDENTIFIED WITH caching_sha2_password BY '${newPassword}';\"`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"ALTER USER '${user}'@'%' IDENTIFIED WITH caching_sha2_password BY '${newPassword}';\"`
|
||||||
|
})
|
||||||
} else if (type === 'mariadb') {
|
} else if (type === 'mariadb') {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"SET PASSWORD FOR '${user}'@'%' = PASSWORD('${newPassword}');\"`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} mysql -u ${rootUser} -p${rootUserPassword} -e \"SET PASSWORD FOR '${user}'@'%' = PASSWORD('${newPassword}');\"`
|
||||||
|
})
|
||||||
|
|
||||||
} else if (type === 'postgresql') {
|
} else if (type === 'postgresql') {
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} psql postgresql://postgres:${rootUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role postgres WITH PASSWORD '${newPassword}'"`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} psql postgresql://postgres:${rootUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role postgres WITH PASSWORD '${newPassword}'"`
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} psql postgresql://${dbUser}:${dbUserPassword}@${id}:5432/${defaultDatabase} -c "ALTER role ${user} WITH PASSWORD '${newPassword}'"`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else if (type === 'mongodb') {
|
} else if (type === 'mongodb') {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} mongo 'mongodb://${rootUser}:${rootUserPassword}@${id}:27017/admin?readPreference=primary&ssl=false' --eval "db.changeUserPassword('${user}','${newPassword}')"`
|
||||||
|
})
|
||||||
|
|
||||||
} else if (type === 'redis') {
|
} else if (type === 'redis') {
|
||||||
await asyncExecShell(
|
await executeDockerCmd({
|
||||||
`DOCKER_HOST=${host} docker exec ${id} redis-cli -u redis://${dbUserPassword}@${id}:6379 --raw CONFIG SET requirepass ${newPassword}`
|
dockerId,
|
||||||
);
|
command: `docker exec ${id} redis-cli -u redis://${dbUserPassword}@${id}:6379 --raw CONFIG SET requirepass ${newPassword}`
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
databaseDbUser = '';
|
databaseDbUser = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: Must integrate remote docker engine
|
||||||
function generateUrl(): string {
|
function generateUrl(): string {
|
||||||
return `${database.type}://${
|
return `${database.type}://${
|
||||||
databaseDbUser ? databaseDbUser + ':' : ''
|
databaseDbUser ? databaseDbUser + ':' : ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user