Skip to content

Commit

Permalink
feat: renamed from kickstart to rocketchat
Browse files Browse the repository at this point in the history
  • Loading branch information
kemboi22 committed Aug 30, 2024
1 parent da6f5ea commit bb5c26c
Show file tree
Hide file tree
Showing 25 changed files with 113 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/javascript-node
{
"name": "ns8-kickstart",
"name": "ns8-rocketchat",
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-18-bullseye",
// Configure tool-specific properties.
"customizations": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clean-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
steps:
- uses: NethServer/ns8-github-actions/.github/actions/delete-image@v1
with:
images: "kickstart"
images: "rocketchat"
delete_image_token: ${{ secrets.IMAGES_CLEANUP_TOKEN }}
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ns8-kickstart
# ns8-rocketchat

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-rocketchat/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,10 +13,10 @@ 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 imageroot/systemd/user/kickstart-app.service imageroot/systemd/user/${modulename}-app.service &&
git mv tests/kickstart.robot tests/${modulename}.robot &&
sed -i "s/kickstart/${modulename}/g" $(find .github/ * -type f) &&
git mv imageroot/systemd/user/rocketchat.service imageroot/systemd/user/${modulename}.service &&
git mv imageroot/systemd/user/rocketchat-app.service imageroot/systemd/user/${modulename}-app.service &&
git mv tests/rocketchat.robot tests/${modulename}.robot &&
sed -i "s/rocketchat/${modulename}/g" $(find .github/ * -type f) &&
git commit -a -m "Repository initialization"
```

Expand All @@ -33,16 +33,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/rocketchat: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": "rocketchat1", "image_name": "rocketchat", "image_url": "ghcr.io/nethserver/rocketchat:latest"}

## Configure

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

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

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

The above command will:
- start and configure the kickstart instance
- start and configure the rocketchat 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/rocketchat1
```

## Uninstall

To uninstall the instance:

remove-module --no-preserve kickstart1
remove-module --no-preserve rocketchat1

## Smarthost setting discovery

Expand All @@ -86,14 +86,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
rocketchat 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 rocketchat 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/rocketchat.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 @@ -102,62 +102,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/rocketchat1/.config/state), it could be nice to verify them
on the root terminal

`runagent -m kickstart1 env`
`runagent -m rocketchat1 env`

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

`runagent -m kickstart1`
`runagent -m rocketchat1`

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/rocketchat1/.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 rocketchat1`
```
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 rocketchat-app
```

you can see what environment variable is inside the container
```
podman exec kickstart-app env
podman exec rocketchat-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=rocketchat
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=rocketchat
MARIADB_DB_PASSWORD=rocketchat
MARIADB_DB_PORT=3306
HOME=/root
```

you can run a shell inside the container

```
podman exec -ti kickstart-app sh
podman exec -ti rocketchat-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/rocketchat:latest

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

Expand Down
10 changes: 5 additions & 5 deletions build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ images=()
# The image will be pushed to GitHub container registry
repobase="${REPOBASE:-ghcr.io/nethserver}"
# Configure the image name
reponame="kickstart"
reponame="rocketchat"

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

# Reuse existing nodebuilder-kickstart container, to speed up builds
if ! buildah containers --format "{{.ContainerName}}" | grep -q nodebuilder-kickstart; then
# Reuse existing nodebuilder-rocketchat container, to speed up builds
if ! buildah containers --format "{{.ContainerName}}" | grep -q nodebuilder-rocketchat; then
echo "Pulling NodeJS runtime..."
buildah from --name nodebuilder-kickstart -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
buildah from --name nodebuilder-rocketchat -v "${PWD}:/usr/src:Z" docker.io/library/node:lts
fi

echo "Build static UI files with node..."
buildah run \
--workingdir=/usr/src/ui \
--env="NODE_OPTIONS=--openssl-legacy-provider" \
nodebuilder-kickstart \
nodebuilder-rocketchat \
sh -c "yarn install && yarn build"

# Add imageroot directory to the container image
Expand Down
4 changes: 2 additions & 2 deletions imageroot/actions/configure-module/80start_services
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ exec 1>&2

touch smarthost.env

systemctl --user enable kickstart.service
systemctl --user restart kickstart.service
systemctl --user enable rocketchat.service
systemctl --user restart rocketchat.service
10 changes: 5 additions & 5 deletions imageroot/actions/configure-module/validate-input.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Configure kickstart",
"$id": "http://nethserver.org/json-schema/task/input/kickstart/configure-module",
"description": "Configure kickstart",
"title": "Configure rocketchat",
"$id": "http://nethserver.org/json-schema/task/input/rocketchat/configure-module",
"description": "Configure rocketchat",
"examples": [
{
"host": "kickstart.domain.org",
"host": "rocketchat.domain.org",
"http2https": true,
"lets_encrypt": true
}
Expand All @@ -19,7 +19,7 @@
"properties": {
"host": {
"type": "string",
"description": "Host name for the application, like 'kickstart.domain.org'",
"description": "Host name for the application, like 'rocketchat.domain.org'",
"format": "hostname",
"pattern": "\\."
},
Expand Down
4 changes: 2 additions & 2 deletions imageroot/actions/create-module/10configure_environment_vars
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def generate_random_password(length):
return password[:length]

MARIADB_ROOT_PASSWORD= generate_random_password(16)
MARIADB_DATABASE="kickstart"
MARIADB_USER="kickstart"
MARIADB_DATABASE="rocketchat"
MARIADB_USER="rocketchat"
MARIADB_PASSWORD=generate_random_password(16)
# mariadb env
mariadb_config = {
Expand Down
10 changes: 5 additions & 5 deletions imageroot/actions/get-configuration/validate-output.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Get kickstart settings",
"$id": "http://nethserver.org/json-schema/task/input/kickstart/get-configuration",
"description": "Get kickstart settings",
"title": "Get rocketchat settings",
"$id": "http://nethserver.org/json-schema/task/input/rocketchat/get-configuration",
"description": "Get rocketchat settings",
"examples": [
{
"host": "kickstart.domain.org",
"host": "rocketchat.domain.org",
"http2https": true,
"lets_encrypt": true
}
Expand All @@ -19,7 +19,7 @@
"properties": {
"host": {
"type": "string",
"description": "Host name for the application, like 'kickstart.domain.org'",
"description": "Host name for the application, like 'rocketchat.domain.org'",
"format": "idn-hostname"
},
"lets_encrypt": {
Expand Down
12 changes: 6 additions & 6 deletions imageroot/actions/restore-module/40restore_database
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ exec 1>&2 # Redirect any output to the journal (stderr)

# Prepare an initialization script that restores the dump file
mkdir -vp initdb.d
mv -v kickstart.sql initdb.d
mv -v rocketchat.sql initdb.d
#do the bash file to restore and exit once done
cat - >initdb.d/zz_kickstart_restore.sh <<'EOS'
cat - >initdb.d/zz_rocketchat_restore.sh <<'EOS'
# Print additional information:
mysql --version
# The script is sourced, override entrypoint args and exit:
Expand All @@ -25,7 +25,7 @@ EOS
trap 'rm -rfv initdb.d/' EXIT

# we start a container to initiate a database and load the dump
# at the end of kickstart_restore.sh the dump is loaded and
# at the end of rocketchat_restore.sh the dump is loaded and
# we exit the container
podman run \
--rm \
Expand All @@ -34,8 +34,8 @@ podman run \
--volume=./initdb.d:/docker-entrypoint-initdb.d:z \
--volume mysql-data:/var/lib/mysql/:Z \
--env MARIADB_ROOT_PASSWORD=Nethesis,1234 \
--env MARIADB_DATABASE=kickstart \
--env MARIADB_USER=kickstart \
--env MARIADB_PASSWORD=kickstart \
--env MARIADB_DATABASE=rocketchat \
--env MARIADB_USER=rocketchat \
--env MARIADB_PASSWORD=rocketchat \
--replace --name=restore_db \
${MARIADB_IMAGE}
4 changes: 2 additions & 2 deletions imageroot/actions/restore-module/80start_services
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ exec 1>&2

touch smarthost.env

systemctl --user enable kickstart.service
systemctl --user restart kickstart.service
systemctl --user enable rocketchat.service
systemctl --user restart rocketchat.service
2 changes: 1 addition & 1 deletion imageroot/bin/discover-smarthost
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ envfile = "smarthost.env"
# Using .tmp suffix: do not overwrite the target file until the new one is
# saved to disk:
with open(envfile + ".tmp", "w") as efp:
# HINT for kickstart: adjust variable names as needed
# HINT for rocketchat: adjust variable names as needed
print(f"SMTP_ENABLED={'1' if smtp_settings['enabled'] else ''}", file=efp)
print(f"SMTP_HOST={smtp_settings['host']}", file=efp)
print(f"SMTP_PORT={smtp_settings['port']}", file=efp)
Expand Down
2 changes: 1 addition & 1 deletion imageroot/bin/module-cleanup-state
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#

rm -vf kickstart.sql
rm -vf rocketchat.sql
6 changes: 3 additions & 3 deletions imageroot/bin/module-dump-state
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

set -e

if ! systemctl --user -q is-active kickstart.service; then
if ! systemctl --user -q is-active rocketchat.service; then
exit 0
fi

podman exec mariadb-app mysqldump \
--databases kickstart \
--databases rocketchat \
--default-character-set=utf8mb4 \
--skip-dump-date \
--ignore-table=mysql.event \
--single-transaction \
--quick \
--add-drop-table > kickstart.sql
--add-drop-table > rocketchat.sql
4 changes: 2 additions & 2 deletions imageroot/etc/state-include.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# List here what you want to save during backup : volumes or file Path


state/kickstart.sql
volumes/kickstart-app
state/rocketchat.sql
volumes/rocketchat-app

2 changes: 1 addition & 1 deletion imageroot/events/smarthost-changed/10reload_services
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

set -e

systemctl --user try-reload-or-restart kickstart.service
systemctl --user try-reload-or-restart rocketchat.service
Loading

0 comments on commit bb5c26c

Please sign in to comment.