mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
nextcloud: Refactor setting admin password
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
833122c931
commit
138cdd6e3f
@ -85,12 +85,12 @@ def setup():
|
|||||||
_configure_systemd()
|
_configure_systemd()
|
||||||
|
|
||||||
|
|
||||||
def _run_occ(*args, capture_output: bool = False,
|
def _run_occ(*args, capture_output: bool = False, check: bool = True,
|
||||||
check: bool = True) -> subprocess.CompletedProcess:
|
env: dict[str, str] | None = None) -> subprocess.CompletedProcess:
|
||||||
"""Run the Nextcloud occ command inside the container."""
|
"""Run the Nextcloud occ command inside the container."""
|
||||||
occ = [
|
env_args = [f'--env={key}={value}' for key, value in (env or {}).items()]
|
||||||
'podman', 'exec', '--user', 'www-data', CONTAINER_NAME, 'php', 'occ'
|
occ = ['podman', 'exec', '--user', 'www-data'
|
||||||
] + list(args)
|
] + env_args + [CONTAINER_NAME, '/var/www/html/occ'] + list(args)
|
||||||
return subprocess.run(occ, capture_output=capture_output, check=check)
|
return subprocess.run(occ, capture_output=capture_output, check=check)
|
||||||
|
|
||||||
|
|
||||||
@ -127,12 +127,8 @@ def set_domain(domain_name: str):
|
|||||||
@privileged
|
@privileged
|
||||||
def set_admin_password(password: str):
|
def set_admin_password(password: str):
|
||||||
"""Set password for owncloud-admin"""
|
"""Set password for owncloud-admin"""
|
||||||
subprocess.run([
|
_run_occ('user:resetpassword', '--password-from-env', GUI_ADMIN,
|
||||||
'podman', 'exec', '--user', 'www-data', f'--env=OC_PASS={password}',
|
env={'OC_PASS': password})
|
||||||
'-it', CONTAINER_NAME, 'sh', '-c',
|
|
||||||
("/var/www/html/occ "
|
|
||||||
f"user:resetpassword --password-from-env {GUI_ADMIN}")
|
|
||||||
], check=True)
|
|
||||||
|
|
||||||
|
|
||||||
@privileged
|
@privileged
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user