Skip to content

Commit

Permalink
feat(docker): addUser command
Browse files Browse the repository at this point in the history
Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Jan 9, 2025
1 parent f9c4a98 commit 3a541ee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const setupUsers = async function(container?: Container) {
console.log('\nCreating test users… 👤')
const users = ['test1', 'test2', 'test3', 'test4', 'test5']
for (const user of users) {
await runExec(['php', 'occ', 'user:add', user, '--password-from-env'], { container, verbose: true, env: ['OC_PASS=' + user] })
await addUser(user, { container, verbose: true })
}
console.log('└─ Done')
}
Expand Down Expand Up @@ -436,6 +436,20 @@ export const getSystemConfig = function(
return runOcc(['config:system:get', key], { container })
}


/**
* Add a user to the Nextcloud in the container.
*/
export const addUser = function(
user: string,
{ container, env=[], verbose=false }: Partial<Omit<RunExecOptions, 'user'>> = {},
) {
return runOcc(
['user:add', user, '--password-from-env'],
{ container, verbose, env: ['OC_PASS=' + user, ...env] }
)
}

const sleep = function(milliseconds: number) {
return new Promise((resolve) => setTimeout(resolve, milliseconds))
}

0 comments on commit 3a541ee

Please # to comment.