Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load LDAP domain from config and enhance Nextcloud service management #112

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions imageroot/actions/configure-module/70ldap

This file was deleted.

8 changes: 4 additions & 4 deletions imageroot/bin/setup-ldap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import sys
import agent
import subprocess
from agent.ldapproxy import Ldapproxy
import json

# Execute occ command
# It returns the process exit code and output
Expand All @@ -41,11 +42,10 @@ def occ(args):
def set_ldap(k, v):
return occ(["ldap:set-config", "s01", k, v])

if len(sys.argv) < 2:
print("setup-ldap: no argument given", file=sys.stderr)
sys.exit(1)
with open('config.json', 'r') as cf:
config = json.loads(cf.read())
cdomain = config.get("domain")

cdomain = sys.argv[1]
commands = []

if not cdomain:
Expand Down
21 changes: 21 additions & 0 deletions imageroot/events/user-domain-changed/20configure_ldap
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

import json
import sys
import agent
import os

event = json.load(sys.stdin)

config = agent.read_envfile("config.env")
nextcloud_domain = config.get('NEXTCLOUD_DOMAIN', '')

if event.get('domain') != nextcloud_domain:
exit(0)

agent.run_helper('systemctl', '--user', '-T', 'try-reload-or-restart', 'nextcloud.service').check_returncode()
stephdl marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions imageroot/systemd/user/nextcloud-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ExecStartPre=/bin/rm -f %t/nextcloud-app.pid %t/nextcloud-app.ctr-id
ExecStartPre=-runagent discover-smarthost
ExecStartPost=runagent wait-startup
ExecStartPost=runagent setup-smtp
ExecStartPost=runagent setup-ldap
ExecStart=/usr/bin/podman run --conmon-pidfile %t/nextcloud-app.pid --cidfile %t/nextcloud-app.ctr-id --cgroups=no-conmon --pod-id-file %t/nextcloud.pod-id --replace -d --name nextcloud-app --env-file=%S/state/config.env --env-file=%S/state/smarthost.env -v nextcloud-app-data:/var/www/html -v %S/state/zzz_nethserver.conf:/usr/local/etc/php-fpm.d/zzz_nethserver.conf:z ${NEXTCLOUD_APP_IMAGE}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/nextcloud-app.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/nextcloud-app.ctr-id
Expand Down
Loading