Skip to content

Commit 031c50a

Browse files
authored
Merge pull request #2 from geniusdynamics/develop
Develop
2 parents d665787 + 0e73d9b commit 031c50a

13 files changed

Lines changed: 426 additions & 113 deletions

File tree

README.md

Lines changed: 220 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,279 @@
11
# ns8-mautic
22

3+
[![Build Status](https://github.com/geniusdynamics/ns8-mautic/workflows/test-module/badge.svg)](https://github.com/geniusdynamics/ns8-mautic/actions)
34

4-
## Install
5+
Mautic module for NethServer 8 (NS8). This repository packages Mautic, an open-source marketing automation platform, with a MariaDB database and exposes it through the NS8 gateway (Traefik) with optional Let's Encrypt TLS.
56

6-
Instantiate the module with:
7+
- **Image**: `ghcr.io/geniusdynamics/mautic:latest`
8+
- **Orchestrator**: NS8 modules (podman-based)
9+
- **Status**: Stable for evaluation and lab use
710

8-
```shell
9-
add-module ghcr.io/geniusdynamics/mautic:latest 1
10-
```
11-
11+
## Table of Contents
12+
13+
- [Overview](#overview)
14+
- [Prerequisites](#prerequisites)
15+
- [Quick Start](#quick-start)
16+
- [Configuration Reference](#configuration-reference)
17+
- [Update the Module](#update-the-module)
18+
- [Uninstall](#uninstall)
19+
- [Smarthost Discovery (SMTP)](#smarthost-discovery-smtp)
20+
- [Debugging](#debugging)
21+
- [Testing](#testing)
22+
- [UI Development and Translation](#ui-development-and-translation)
23+
- [Troubleshooting](#troubleshooting)
24+
- [Contributing](#contributing)
25+
- [License](#license)
26+
27+
## Overview
28+
29+
This module integrates Mautic into NethServer 8, providing a complete marketing automation solution. It includes:
30+
31+
- Mautic application container
32+
- MariaDB database for data persistence
33+
- Traefik reverse proxy for secure access
34+
- Optional Let's Encrypt SSL certificates
35+
- UI components for NS8 management interface
1236

13-
The output of the command will return the instance name.
14-
Output example:
37+
The module supports dynamic SMTP configuration via smarthost discovery and includes comprehensive testing with Robot Framework.
1538

16-
{"module_id": "mautic1", "image_name": "mautic", "image_url": "ghcr.io/geniusdynamics/mautic:latest"}
39+
---
1740

18-
## Configure
41+
## Prerequisites
1942

20-
Let's assume that the mattermost instance is named `mautic1`.
43+
Before installing the ns8-mautic module, ensure you have:
2144

22-
Launch `configure-module`, by setting the following parameters:
23-
- `host`: a fully qualified domain name for the application
24-
- `http2https`: enable or disable HTTP to HTTPS redirection (true/false)
25-
- `lets_encrypt`: enable or disable Let's Encrypt certificate (true/false)
45+
- A running NethServer 8 (NS8) node with admin access
46+
- A public DNS record pointing to your NS8 gateway (e.g., `mautic.example.com`)
47+
- Ports 80 and 443 reachable from the internet if using Let's Encrypt for automatic HTTPS
48+
- Basic familiarity with NS8 module management and Podman containers
2649

50+
## Quick Start
2751

28-
Example:
52+
Follow these steps to install, configure, and access Mautic on NS8:
2953

54+
### 1. Install the Module
55+
56+
Install the module image and create an instance:
57+
58+
```bash
59+
add-module ghcr.io/geniusdynamics/mautic:latest 1
3060
```
31-
api-cli run configure-module --agent module/mautic1 --data - <<EOF
61+
62+
This command returns a JSON object. Note the `module_id`, for example:
63+
64+
```json
3265
{
33-
"host": "mautic.domain.com",
66+
"module_id": "mautic1",
67+
"image_name": "mautic",
68+
"image_url": "ghcr.io/geniusdynamics/mautic:latest"
69+
}
70+
```
71+
72+
### 2. Configure the Instance
73+
74+
Replace `mautic1` with your instance ID and adjust the domain and options:
75+
76+
```bash
77+
api-cli run configure-module --agent module/mautic1 --data - <<'EOF'
78+
{
79+
"host": "mautic.example.com",
3480
"http2https": true,
3581
"lets_encrypt": false
3682
}
3783
EOF
3884
```
3985

40-
The above command will:
41-
- start and configure the mautic instance
42-
- configure a virtual host for trafik to access the instance
86+
This configuration:
4387

44-
## Get the configuration
45-
You can retrieve the configuration with
88+
- Starts and configures the Mautic instance
89+
- Sets up a virtual host for Traefik to route HTTP/HTTPS traffic to Mautic
90+
- Enables HTTP to HTTPS redirection if `http2https` is true
4691

47-
```
92+
### 3. Verify Configuration
93+
94+
Get the current configuration to ensure everything is set up correctly:
95+
96+
```bash
4897
api-cli run get-configuration --agent module/mautic1
4998
```
5099

100+
### 4. Access the Application
101+
102+
- **URL**: `http(s)://mautic.example.com`
103+
- If `lets_encrypt` is `true`, a certificate will be requested automatically
104+
- If `lets_encrypt` is `false`, provide your own TLS certificate or use HTTP for internal testing
105+
- Set `http2https` to `true` if you plan to terminate TLS at the NS8 gateway
106+
107+
Once configured, you can log in to Mautic using the default credentials (check Mautic documentation for initial setup).
108+
109+
---
110+
111+
## Configuration reference
112+
113+
These inputs are accepted by configure-module:
114+
115+
- host (string, required): Fully qualified domain name for public access
116+
- http2https (boolean, default: true): Redirect plain HTTP to HTTPS at the gateway
117+
- lets_encrypt (boolean, default: false): Issue a Let's Encrypt certificate for host
118+
119+
Example without Let's Encrypt (internal lab):
120+
121+
```bash
122+
api-cli run configure-module --agent module/mautic1 --data - <<'EOF'
123+
{
124+
"host": "mautic.lab.local",
125+
"http2https": false,
126+
"lets_encrypt": false
127+
}
128+
EOF
129+
```
130+
131+
Example with Let's Encrypt:
132+
133+
```bash
134+
api-cli run configure-module --agent module/mautic1 --data - <<'EOF'
135+
{
136+
"host": "mautic.example.com",
137+
"http2https": true,
138+
"lets_encrypt": true
139+
}
140+
EOF
141+
```
142+
143+
---
144+
145+
## Update the module
146+
147+
To update the instance to the latest image:
148+
149+
```bash
150+
api-cli run update-module --data '{"module_url":"ghcr.io/geniusdynamics/mautic:latest","instances":["mautic1"],"force":true}'
151+
```
152+
153+
---
154+
51155
## Uninstall
52156

53-
To uninstall the instance:
54-
```shell
55-
remove-module --no-preserve mautic1
157+
To remove an instance and its data:
158+
159+
```bash
160+
remove-module --no-preserve mautic1
56161
```
57-
58162

59-
## Smarthost setting discovery
163+
Caution: --no-preserve deletes the instance data.
60164

61-
Some configuration settings, like the smarthost setup, are not part of the
62-
`configure-module` action input: they are discovered by looking at some
63-
Redis keys. To ensure the module is always up-to-date with the
64-
centralized [smarthost
65-
setup](https://geniusdynamics.github.io/ns8-core/core/smarthost/) every time
66-
mautic starts, the command `bin/discover-smarthost` runs and refreshes
67-
the `state/smarthost.env` file with fresh values from Redis.
165+
---
68166

69-
Furthermore if smarthost setup is changed when mautic is already
70-
running, the event handler `events/smarthost-changed/10reload_services`
71-
restarts the main module service.
167+
## Smarthost discovery (SMTP)
72168

73-
See also the `systemd/user/mautic.service` file.
169+
Some configuration, like outbound SMTP (smarthost), is not passed directly to configure-module. Instead, it is discovered dynamically through Redis keys.
74170

75-
This setting discovery is just an example to understand how the module is
76-
expected to work: it can be rewritten or discarded completely.
171+
On every Mautic start, the command bin/discover-smarthost refreshes state/smarthost.env with values from Redis to keep the module aligned with the centralized smarthost setup:
77172

78-
## Debug
173+
- If the smarthost is changed while Mautic is running, the handler events/smarthost-changed/10reload_services restarts the main module service
174+
- See also systemd/user/mautic.service
79175

80-
some CLI are needed to debug
176+
This mechanism is an example implementation and can be adapted or replaced.
81177

82-
- The module runs under an agent that initiate a lot of environment variables (in /home/mautic1/.config/state), it could be nice to verify them
83-
on the root terminal
178+
---
84179

85-
`runagent -m mautic1 env`
180+
## Debugging
86181

87-
- you can become runagent for testing scripts and initiate all environment variables
88-
89-
`runagent -m mautic1`
182+
Useful commands when working with an instance named mautic1.
90183

91-
the path become :
92-
```
93-
echo $PATH
94-
/home/mautic1/.config/bin:/usr/local/agent/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/
184+
- Inspect environment from the root terminal (loads agent env from /home/mautic1/.config/state):
185+
186+
```bash
187+
runagent -m mautic1 env
95188
```
96189

97-
- if you want to debug a container or see environment inside
98-
`runagent -m mautic1`
99-
```
100-
podman ps
101-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
102-
d292c6ff28e9 localhost/podman-pause:4.6.1-1702418000 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp 80b8de25945f-infra
103-
d8df02bf6f4a docker.io/library/mariadb:10.11.5 --character-set-s... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp mariadb-app
104-
9e58e5bd676f docker.io/library/nginx:stable-alpine3.17 nginx -g daemon o... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp mautic-app
190+
- Enter the agent environment for testing scripts and inheriting module variables:
191+
192+
```bash
193+
runagent -m mautic1
105194
```
106195

107-
you can see what environment variable is inside the container
196+
Your PATH will include:
197+
108198
```
109-
podman exec mautic-app env
110-
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
111-
TERM=xterm
112-
PKG_RELEASE=1
113-
MARIADB_DB_HOST=127.0.0.1
114-
MARIADB_DB_NAME=mautic
115-
MARIADB_IMAGE=docker.io/mariadb:10.11.5
116-
MARIADB_DB_TYPE=mysql
117-
container=podman
118-
NGINX_VERSION=1.24.0
119-
NJS_VERSION=0.7.12
120-
MARIADB_DB_USER=mautic
121-
MARIADB_DB_PASSWORD=mautic
122-
MARIADB_DB_PORT=3306
123-
HOME=/root
199+
/home/mautic1/.config/bin:/usr/local/agent/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/
200+
```
201+
202+
- Inspect containers:
203+
204+
```bash
205+
podman ps
206+
# Example output
207+
# CONTAINER ID IMAGE COMMAND STATUS NAMES
208+
# ... docker.io/library/mariadb:10.11.5 --character-set-s... Up mariadb-app
209+
# ... docker.io/library/nginx:stable-alpine3.17 nginx -g daemon o... Up mautic-app
124210
```
125211

126-
you can run a shell inside the container
212+
- Print environment variables inside the app container:
127213

214+
```bash
215+
podman exec mautic-app env
128216
```
129-
podman exec -ti mautic-app sh
130-
/ #
217+
218+
- Open a shell in the app container:
219+
220+
```bash
221+
podman exec -ti mautic-app sh
131222
```
223+
224+
---
225+
132226
## Testing
133227

134-
Test the module using the `test-module.sh` script:
228+
Run the end-to-end tests with Robot Framework using the helper script:
229+
230+
```bash
231+
./test-module.sh <NODE_ADDR> ghcr.io/geniusdynamics/mautic:latest
232+
```
233+
234+
See: https://robotframework.org/
235+
236+
---
237+
238+
For detailed UI development instructions, see the [NS8 UI Developer Manual](https://nethserver.github.io/ns8-core/ui/modules/#module-ui-development).
239+
240+
### Translation Management
241+
242+
Translations are managed on Weblate: https://hosted.weblate.org/projects/ns8/
243+
244+
To set up translation syncing:
245+
246+
1. Install the GitHub Weblate app: https://docs.weblate.org/en/latest/admin/continuous.html#github-setup
247+
2. Add the repository on https://hosted.weblate.org (or ask a NethServer developer to include it in the NS8 Weblate project)
248+
249+
Translation files are located in `ui/public/i18n/` and support multiple languages including English, German, Spanish, and more.
250+
251+
---
252+
253+
## Troubleshooting tips
254+
255+
- DNS and certificates: ensure the host value has a valid public DNS A/AAAA record pointing to your NS8 gateway before enabling Let's Encrypt
256+
- HTTP to HTTPS redirection: set http2https to true when a certificate is available at the gateway
257+
- Connectivity: verify that port mappings and the Traefik route are active; use podman ps and journal logs
258+
259+
---
135260

261+
## Contributing
136262

137-
./test-module.sh <NODE_ADDR> ghcr.io/geniusdynamics/mautic:latest
263+
Issues and pull requests are welcome! When submitting changes, please include:
138264

139-
The tests are made using [Robot Framework](https://robotframework.org/)
265+
- A short description of the change and the motivation
266+
- Test notes (how you verified the change)
267+
- Any related documentation updates
140268

141-
## UI translation
269+
### Development Workflow
142270

143-
Translated with [Weblate](https://hosted.weblate.org/projects/ns8/).
271+
1. Fork the repository
272+
2. Create a feature branch: `git checkout -b feature/your-feature-name`
273+
3. Make your changes and test thoroughly
274+
4. Run tests: `./test-module.sh <NODE_ADDR> ghcr.io/geniusdynamics/mautic:latest`
275+
5. Submit a pull request with a clear description
144276

145-
To setup the translation process:
277+
## License
146278

147-
- add [GitHub Weblate app](https://docs.weblate.org/en/latest/admin/continuous.html#github-setup) to your repository
148-
- add your repository to [hosted.weblate.org]((https://hosted.weblate.org) or ask a NethServer developer to add it to ns8 Weblate project
279+
This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.

build-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ images=()
1414
repobase="${REPOBASE:-ghcr.io/geniusdynamics}"
1515
# Configure the image name
1616
reponame="mautic"
17-
mautic_version="6-apache"
17+
mautic_version="6.0.4-20250818-apache"
1818

1919
# Create a new empty container image
2020
container=$(buildah from scratch)

imageroot/actions/configure-module/10configure_environment_vars

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import agent
1212
# Try to parse the stdin as JSON.
1313
# If parsing fails, output everything to stderr
1414
data = json.load(sys.stdin)
15-
15+
host = data.get("host")
16+
mautic_env = {
17+
"SITE_URL": f"https://{host}",
18+
}
19+
agent.write_envfile("mautic.env", mautic_env)
1620

1721
# just before starting systemd unit
1822
# agent.dump_env()

0 commit comments

Comments
 (0)