Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
compgeniuses committed Jan 28, 2024
1 parent ddf6c04 commit 35e0850
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ns8-kickstart
# ns8-joplin

This is a template module for [NethServer 8](https://github.com/NethServer/ns8-core).
To start a new module from it:

1. Click on [Use this template](https://github.com/NethServer/ns8-kickstart/generate).
1. Click on [Use this template](https://github.com/NethServer/ns8-joplin/generate).
Name your repo with `ns8-` prefix (e.g. `ns8-mymodule`).
Do not end your module name with a number, like ~~`ns8-baaad2`~~!

Expand All @@ -13,9 +13,9 @@ To start a new module from it:
1. Rename some references inside the repo:
```
modulename=$(basename $(pwd) | sed 's/^ns8-//')
git mv imageroot/systemd/user/kickstart.service imageroot/systemd/user/${modulename}.service
git mv tests/kickstart.robot tests/${modulename}.robot
sed -i "s/kickstart/${modulename}/g" $(find .github/ * -type f)
git mv imageroot/systemd/user/joplin.service imageroot/systemd/user/${modulename}.service
git mv tests/joplin.robot tests/${modulename}.robot
sed -i "s/joplin/${modulename}/g" $(find .github/ * -type f)
git commit -a -m "Repository initialization"
```

Expand All @@ -32,16 +32,16 @@ To start a new module from it:

Instantiate the module with:

add-module ghcr.io/nethserver/kickstart:latest 1
add-module ghcr.io/nethserver/joplin:latest 1

The output of the command will return the instance name.
Output example:

{"module_id": "kickstart1", "image_name": "kickstart", "image_url": "ghcr.io/nethserver/kickstart:latest"}
{"module_id": "joplin1", "image_name": "joplin", "image_url": "ghcr.io/nethserver/joplin:latest"}

## Configure

Let's assume that the mattermost instance is named `kickstart1`.
Let's assume that the mattermost instance is named `joplin1`.

Launch `configure-module`, by setting the following parameters:
- `host`: a fully qualified domain name for the application
Expand All @@ -50,33 +50,42 @@ Launch `configure-module`, by setting the following parameters:


Example:
```
api-cli run module/joplin1/configure-module --data '{"host": "joplin.domain.com","lets_encrypt": false,"http2https": true}'
```

Multiple

```
api-cli run configure-module --agent module/kickstart1 --data - <<EOF
api-cli run configure-module --agent module/joplin1 --data - <<EOF
{
"host": "kickstart.domain.com",
"host": "joplin.domain.com",
"http2https": true,
"lets_encrypt": false
}
EOF
```

The above command will:
- start and configure the kickstart instance
- start and configure the joplin instance
- configure a virtual host for trafik to access the instance

## Get the configuration
You can retrieve the configuration with

```
api-cli run get-configuration --agent module/kickstart1
api-cli run get-configuration --agent module/joplin1
```
## update

To update the instance:

api-cli run update-module --data '{"module_url":"ghcr.io/compgeniuses/joplin:latest","instances":["joplin1"],"force":true}'
## Uninstall

To uninstall the instance:

remove-module --no-preserve kickstart1
remove-module --no-preserve joplin1

## Smarthost setting discovery

Expand All @@ -85,14 +94,14 @@ Some configuration settings, like the smarthost setup, are not part of the
Redis keys. To ensure the module is always up-to-date with the
centralized [smarthost
setup](https://nethserver.github.io/ns8-core/core/smarthost/) every time
kickstart starts, the command `bin/discover-smarthost` runs and refreshes
joplin starts, the command `bin/discover-smarthost` runs and refreshes
the `state/smarthost.env` file with fresh values from Redis.

Furthermore if smarthost setup is changed when kickstart is already
Furthermore if smarthost setup is changed when joplin is already
running, the event handler `events/smarthost-changed/10reload_services`
restarts the main module service.

See also the `systemd/user/kickstart.service` file.
See also the `systemd/user/joplin.service` file.

This setting discovery is just an example to understand how the module is
expected to work: it can be rewritten or discarded completely.
Expand All @@ -101,62 +110,62 @@ expected to work: it can be rewritten or discarded completely.

some CLI are needed to debug

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

`runagent -m kickstart1 env`
`runagent -m joplin1 env`

- you can become runagent for testing scripts and initiate all environment variables

`runagent -m kickstart1`
`runagent -m joplin1`

the path become :
```
echo $PATH
/home/kickstart1/.config/bin:/usr/local/agent/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/
/home/joplin1/.config/bin:/usr/local/agent/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/
```

- if you want to debug a container or see environment inside
`runagent -m kickstart1`
`runagent -m joplin1`
```
podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d292c6ff28e9 localhost/podman-pause:4.6.1-1702418000 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp 80b8de25945f-infra
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
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 kickstart-app
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 joplin-app
```

you can see what environment variable is inside the container
```
podman exec kickstart-app env
podman exec joplin-app env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
PKG_RELEASE=1
MARIADB_DB_HOST=127.0.0.1
MARIADB_DB_NAME=kickstart
MARIADB_DB_NAME=joplin
MARIADB_IMAGE=docker.io/mariadb:10.11.5
MARIADB_DB_TYPE=mysql
container=podman
NGINX_VERSION=1.24.0
NJS_VERSION=0.7.12
MARIADB_DB_USER=kickstart
MARIADB_DB_PASSWORD=kickstart
MARIADB_DB_USER=joplin
MARIADB_DB_PASSWORD=joplin
MARIADB_DB_PORT=3306
HOME=/root
```

you can run a shell inside the container

```
podman exec -ti kickstart-app sh
podman exec -ti joplin-app sh
/ #
```
## Testing

Test the module using the `test-module.sh` script:


./test-module.sh <NODE_ADDR> ghcr.io/nethserver/kickstart:latest
./test-module.sh <NODE_ADDR> ghcr.io/nethserver/joplin:latest

The tests are made using [Robot Framework](https://robotframework.org/)

Expand Down

0 comments on commit 35e0850

Please sign in to comment.