Implemented helper role docker-central-database and refactored code

This commit is contained in:
2025-02-04 18:14:37 +01:00
parent cb6a42e97d
commit 5503326ea6
91 changed files with 358 additions and 237 deletions

View File

@@ -135,12 +135,12 @@ The role includes a **`systemd` service** that runs the deployment script whenev
Example `nginx-docker-cert-deploy.service.j2`:
```ini
[Unit]
Description=Let's Encrypt deploy to {{docker_compose_instance_directory}}
Description=Let's Encrypt deploy to {{docker_compose.directories.instance}}
OnFailure=systemd-notifier.cymais@%n.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash {{path_administrator_scripts}}/nginx-docker-cert-deploy.sh {{primary_domain}} {{docker_compose_instance_directory}}
ExecStart=/usr/bin/bash {{path_administrator_scripts}}/nginx-docker-cert-deploy.sh {{primary_domain}} {{docker_compose.directories.instance}}
```
---

View File

@@ -2,29 +2,29 @@
# Check if the necessary parameters are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <domain> <docker_compose_instance_directory>"
echo "Usage: $0 <domain> <docker_compose.directories.instance>"
exit 1
fi
# Assign parameters
domain="$1"
docker_compose_instance_directory="$2"
docker_compose.directories.instance="$2"
# Copy certificates
cp -RvL "/etc/letsencrypt/live/$domain/"* "$docker_compose_instance_directory/certs" || exit 1
cp -RvL "/etc/letsencrypt/live/$domain/"* "$docker_compose.directories.instance/certs" || exit 1
# This code is optimized for mailu
cp -v "/etc/letsencrypt/live/$domain/privkey.pem" "$docker_compose_instance_directory/certs/key.pem" || exit 1
cp -v "/etc/letsencrypt/live/$domain/fullchain.pem" "$docker_compose_instance_directory/certs/cert.pem" || exit 1
cp -v "/etc/letsencrypt/live/$domain/privkey.pem" "$docker_compose.directories.instance/certs/key.pem" || exit 1
cp -v "/etc/letsencrypt/live/$domain/fullchain.pem" "$docker_compose.directories.instance/certs/cert.pem" || exit 1
# Set correct reading rights
chmod a+r -v "$docker_compose_instance_directory/certs/"*
chmod a+r -v "$docker_compose.directories.instance/certs/"*
# Flag to track if any Nginx reload was successful
nginx_reload_successful=false
# Reload Nginx in all containers within the Docker Compose setup
cd "$docker_compose_instance_directory" || exit 1
cd "$docker_compose.directories.instance" || exit 1
# Iterate over all services
for service in $(docker compose ps --services); do

View File

@@ -1,7 +1,7 @@
[Unit]
Description=Let's Encrypt deploy to {{docker_compose_instance_directory}}
Description=Let's Encrypt deploy to {{docker_compose.directories.instance}}
OnFailure=systemd-notifier.cymais@%n.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash {{path_administrator_scripts}}/nginx-docker-cert-deploy.sh {{domain}} {{docker_compose_instance_directory}}
ExecStart=/usr/bin/bash {{path_administrator_scripts}}/nginx-docker-cert-deploy.sh {{domain}} {{docker_compose.directories.instance}}