Skip to content

Commit

Permalink
Merge pull request #1 from geniusdynamics/dev
Browse files Browse the repository at this point in the history
road to RC
  • Loading branch information
compgeniuses authored Jul 28, 2024
2 parents b49a60d + 728c952 commit 2ede93a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 7 deletions.
25 changes: 24 additions & 1 deletion imageroot/actions/configure-module/10configure_environment_vars
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,30 @@ data = json.load(sys.stdin)

#This is specific to you module, so you need to change it accordingly.
# Upper case to set environment variable and minor case to read from stdin

# Email Settings
# Add EMAIL SETTINGS
rdb = agent.redis_connect(use_replica=True)
smtp_settings = agent.get_smarthost_settings(rdb)
ALLOWED_HOSTS = data.get('host')
agent.set_env('ALLOWED_HOSTS', ALLOWED_HOSTS)
SMTP_HOST=smtp_settings['host']
SMTP_PORT=smtp_settings['port']
SMTP_USER=smtp_settings['username']
SMTP_PASSWORD=smtp_settings['password']
SMTP_ENCRYPTION=smtp_settings['encrypt_smtp']
SMTP_TLSVERIFY='True' if smtp_settings['tls_verify'] else 'False'
SMTP_SSLVERIFY='False' if smtp_settings['tls_verify'] else 'True'

chief_config = {
"EMAIL_HOST": SMTP_HOST,
"EMAIL_PORT": SMTP_PORT,
"EMAIL_HOST_USER": SMTP_USER,
"EMAIL_HOST_PASSWORD": SMTP_PASSWORD,
"EMAIL_USE_TLS": SMTP_ENCRYPTION,
"EMAIL_USE_SSL": not SMTP_ENCRYPTION,
"ALLOWED_HOSTS": ALLOWED_HOSTS,
}

agent.write_envfile("chief.env", chief_config)
# just before starting systemd unit
agent.dump_env()
4 changes: 1 addition & 3 deletions imageroot/actions/restore-module/40restore_database
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ podman run \
--volume=./restore:/docker-entrypoint-initdb.d/:Z \
--volume=postgres-data:/var/lib/postgresql/data:Z \
--replace --name=restore_db \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=Nethesis,1234 \
--env POSTGRES_DB=chiefonboarding \
--env-file=database.env \
--env TZ=UTC \
"${POSTGRES_IMAGE}" < chiefonboarding.pg_dump

Expand Down
17 changes: 17 additions & 0 deletions imageroot/actions/restore-module/80start_services
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

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

# Redirect any output to the journal (stderr)
exec 1>&2

# If the control reaches this step, the service can be enabled and started

touch smarthost.env

systemctl --user enable chiefonboarding.service
systemctl --user restart chiefonboarding.service
5 changes: 4 additions & 1 deletion imageroot/etc/state-include.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# List here what you want to save during backup : volumes or file Path


state/chiefonboarding.sql
state/chiefonboarding.pg_dump
state/app.env
state/database.env
state/chief.env
volumes/chiefonboarding-app

2 changes: 1 addition & 1 deletion imageroot/systemd/user/chiefonboarding-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/chiefonboarding-app.pid \
--cidfile %t/chiefonboarding-app.ctr-id --cgroups=no-conmon \
--pod-id-file %t/chiefonboarding.pod-id --replace -d --name chiefonboarding-app \
--env-file=%S/state/app.env \
--env ALLOWED_HOSTS=${ALLOWED_HOSTS} \
--env-file=%S/state/chief.env \
${CHIEFONBOARDING_IMAGE}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/chiefonboarding-app.ctr-id -t 10
ExecReload=/usr/bin/podman kill -s HUP chiefonboarding-app
Expand Down
3 changes: 2 additions & 1 deletion imageroot/systemd/user/postgresql-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ After=chiefonboarding.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
EnvironmentFile=%S/state/database.env
# EnvironmentFile=%S/state/secrets/passwords.secret
Restart=always
TimeoutStopSec=70
Expand All @@ -24,7 +25,7 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/postgresql-app.pid \
--volume %S/state/restore/:/docker-entrypoint-initdb.d/:Z \
--env TZ=UTC \
${POSTGRES_IMAGE}
ExecStartPost=/usr/bin/bash -c "while ! podman exec postgresql-app psql -U postgres -d chiefonboarding ; do sleep 5 ; done"
# ExecStartPost=/usr/bin/bash -c "while ! podman exec postgresql-app psql -U postgres -d ${POSTGRES_PASSWORD} ; do sleep 5 ; done"
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/postgresql-app.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/postgresql-app.ctr-id
ExecReload=/usr/bin/podman kill -s HUP postgresql-app
Expand Down

0 comments on commit 2ede93a

Please sign in to comment.