Skip to content

Commit

Permalink
Add systemd unit for sogo, mariadb-app, sogo-app
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Nov 27, 2023
1 parent bfab8e1 commit fd6d2f5
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 16 deletions.
39 changes: 39 additions & 0 deletions imageroot/systemd/user/mariadb-app.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

[Unit]
Description=Podman mariadb-app.service
BindsTo=sogo.service
After=sogo.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
Restart=always
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/mariadb-app.pid %t/mariadb-app.ctr-id
ExecStart=/usr/bin/podman run --conmon-pidfile %t/mariadb-app.pid \
--cidfile %t/mariadb-app.ctr-id --cgroups=no-conmon \
--pod-id-file %t/sogo.pod-id --replace -d --name mariadb-app \
--env-file=%S/state/environment \
--volume mysql-data:/var/lib/mysql/:Z \
--env MARIADB_ROOT_PASSWORD=Nethesis,1234 \
--env MARIADB_DATABASE=sogo \
--env MARIADB_USER=sogo \
--env MARIADB_PASSWORD=Nethesis,1234 \
--env MARIADB_AUTO_UPGRADE=1 \
${MARIADB_IMAGE} \
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
ExecStartPost=/usr/bin/podman exec mariadb-app /bin/bash -c 'printf "[client] \npassword=Nethesis,1234" > /root/.my.cnf'
ExecStartPost=/usr/bin/podman exec mariadb-app /bin/bash -c "while ! mysqladmin ping -h localhost -P 3306 -u root; do sleep 1; done"
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/mariadb-app.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/mariadb-app.ctr-id
ExecReload=/usr/bin/podman kill -s HUP mariadb-app
SyslogIdentifier=%u
PIDFile=%t/mariadb-app.pid
Type=forking

[Install]
WantedBy=default.target
42 changes: 42 additions & 0 deletions imageroot/systemd/user/sogo-app.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (C) 2023 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

[Unit]
Description=Podman sogo-app.service
BindsTo=sogo.service
After=sogo.service mariadb-app.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
EnvironmentFile=-%S/state/discovery.env
WorkingDirectory=%S/state
Restart=always
TimeoutStopSec=70
ExecStartPre=/bin/mkdir -p config
ExecStartPre=/bin/rm -f %t/sogo-app.pid %t/sogo-app.ctr-id
ExecStartPre=runagent discover-ldap
ExecStartPre=/usr/local/bin/runagent discover-service
ExecStart=/usr/bin/podman run --conmon-pidfile %t/sogo-app.pid \
--cidfile %t/sogo-app.ctr-id --cgroups=no-conmon \
--pod-id-file %t/sogo.pod-id --replace -d --name sogo-app \
--volume ./config:/etc/sogo:Z \
--env=sogo_* \
--env sogo_DB_TYPE=mysql \
--env sogo_DB_HOST=127.0.0.1 \
--env sogo_DB_PORT=3306 \
--env sogo_DB_USER=sogo \
--env sogo_DB_PASSWORD=Nethesis,1234 \
--env sogo_DB_NAME=sogo \
${sogo_IMAGE}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/sogo-app.ctr-id -t 10
ExecReload=/usr/bin/podman kill -s HUP sogo-app
SyslogIdentifier=%u
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/sogo-app.ctr-id
PIDFile=%t/sogo-app.pid
Type=forking

[Install]
WantedBy=default.target
31 changes: 15 additions & 16 deletions imageroot/systemd/user/sogo.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@
# This systemd unit starts a sogo instance using Podman.
# Most parts of this file come from podman-generate-systemd.
#

[Unit]
Description=sogo server
Description=Podman sogo.service
Requires=mariadb-app.service sogo-app.service
Before=mariadb-app.service sogo-app.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
WorkingDirectory=%S/state
EnvironmentFile=-%S/state/environment
Restart=always
ExecStartPre=/bin/rm -f %t/sogo.pid %t/sogo.ctr-id
ExecStartPre=-runagent discover-smarthost
ExecStart=/usr/bin/podman run \
--detach \
--conmon-pidfile=%t/sogo.pid \
--cidfile=%t/sogo.ctr-id \
--cgroups=no-conmon \
--replace --name=%N \
--publish=127.0.0.1:${TCP_PORT}:8080 \
--env-file=smarthost.env \
${ECHO_SERVER_IMAGE}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/sogo.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/sogo.ctr-id
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/sogo.pid %t/sogo.pod-id
ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/sogo.pid \
--pod-id-file %t/sogo.pod-id \
--name sogo \
--publish 127.0.0.1:${TCP_PORT}:20001 \
--replace
ExecStart=/usr/bin/podman pod start --pod-id-file %t/sogo.pod-id
ExecStop=/usr/bin/podman pod stop --ignore --pod-id-file %t/sogo.pod-id -t 10
ExecStopPost=/usr/bin/podman pod rm --ignore -f --pod-id-file %t/sogo.pod-id
PIDFile=%t/sogo.pid
Type=forking

Expand Down

0 comments on commit fd6d2f5

Please sign in to comment.