Skip to content

Commit

Permalink
Merge pull request #112 from NethServer/sdl-7103
Browse files Browse the repository at this point in the history
Load LDAP domain from config and enhance Nextcloud service management NethServer/dev#7103
  • Loading branch information
stephdl authored Nov 22, 2024
2 parents 333b724 + fb298c5 commit 60eb865
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
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-restart', 'nextcloud.service').check_returncode()
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

0 comments on commit 60eb865

Please sign in to comment.