From 63bb49b9b008085a0e3ce01cc8ba6d02afde1125 Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Tue, 21 Nov 2023 18:23:36 +0100 Subject: [PATCH] Repository initialization --- .github/workflows/clean-registry.yml | 2 +- README.md | 34 +++++++++---------- build-images.sh | 10 +++--- .../actions/configure-module/20configure | 6 ++-- .../actions/configure-module/80start_services | 2 +- .../configure-module/validate-input.json | 4 +-- .../get-configuration/validate-output.json | 4 +-- imageroot/bin/discover-smarthost | 2 +- .../smarthost-changed/10reload_services | 2 +- .../user/{kickstart.service => sogo.service} | 16 ++++----- tests/{kickstart.robot => sogo.robot} | 10 +++--- ui/README.md | 4 +-- ui/public/metadata.json | 10 +++--- 13 files changed, 53 insertions(+), 53 deletions(-) rename imageroot/systemd/user/{kickstart.service => sogo.service} (58%) rename tests/{kickstart.robot => sogo.robot} (76%) diff --git a/.github/workflows/clean-registry.yml b/.github/workflows/clean-registry.yml index 82e36ae..ee0b6ab 100644 --- a/.github/workflows/clean-registry.yml +++ b/.github/workflows/clean-registry.yml @@ -15,5 +15,5 @@ jobs: steps: - uses: NethServer/ns8-github-actions/.github/actions/delete-image@v1 with: - images: "kickstart" + images: "sogo" delete_image_token: ${{ secrets.IMAGES_CLEANUP_TOKEN }} diff --git a/README.md b/README.md index 128203b..61ff4c5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# ns8-kickstart +# ns8-sogo 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-sogo/generate). Name your repo with `ns8-` prefix (e.g. `ns8-mymodule`). Do not end your module name with a number, like ~~`ns8-baaad2`~~! @@ -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/sogo.service imageroot/systemd/user/${modulename}.service + git mv tests/sogo.robot tests/${modulename}.robot + sed -i "s/sogo/${modulename}/g" $(find .github/ * -type f) git commit -a -m "Repository initialization" ``` @@ -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/sogo: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": "sogo1", "image_name": "sogo", "image_url": "ghcr.io/nethserver/sogo:latest"} ## Configure -Let's assume that the kickstart instance is named `kickstart1`. +Let's assume that the sogo instance is named `sogo1`. Launch `configure-module`, by setting the following parameters: - ``: @@ -50,16 +50,16 @@ Launch `configure-module`, by setting the following parameters: Example: - api-cli run module/kickstart1/configure-module --data '{}' + api-cli run module/sogo1/configure-module --data '{}' The above command will: -- start and configure the kickstart instance +- start and configure the sogo instance - (describe configuration process) - ... -Send a test HTTP request to the kickstart backend service: +Send a test HTTP request to the sogo backend service: - curl http://127.0.0.1/kickstart/ + curl http://127.0.0.1/sogo/ ## Smarthost setting discovery @@ -68,14 +68,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 +sogo 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 sogo 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/sogo.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. @@ -84,14 +84,14 @@ expected to work: it can be rewritten or discarded completely. To uninstall the instance: - remove-module --no-preserve kickstart1 + remove-module --no-preserve sogo1 ## Testing Test the module using the `test-module.sh` script: - ./test-module.sh ghcr.io/nethserver/kickstart:latest + ./test-module.sh ghcr.io/nethserver/sogo:latest The tests are made using [Robot Framework](https://robotframework.org/) diff --git a/build-images.sh b/build-images.sh index 013671d..8b0150e 100644 --- a/build-images.sh +++ b/build-images.sh @@ -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="sogo" # 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-sogo container, to speed up builds +if ! buildah containers --format "{{.ContainerName}}" | grep -q nodebuilder-sogo; then echo "Pulling NodeJS runtime..." - buildah from --name nodebuilder-kickstart -v "${PWD}:/usr/src:Z" docker.io/library/node:lts + buildah from --name nodebuilder-sogo -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-sogo \ sh -c "yarn install && yarn build" # Add imageroot directory to the container image diff --git a/imageroot/actions/configure-module/20configure b/imageroot/actions/configure-module/20configure index 55976a8..43bef9f 100755 --- a/imageroot/actions/configure-module/20configure +++ b/imageroot/actions/configure-module/20configure @@ -15,9 +15,9 @@ request = json.load(sys.stdin) # TODO: do something with the request payload. For example configure a # custom route in our web router. Here the path is hardcoded as -# 'kickstart'. +# 'sogo'. -# Configure Traefik to route "/kickstart" path requests to the kickstart service +# Configure Traefik to route "/sogo" path requests to the sogo service response = agent.tasks.run( agent_id=agent.resolve_agent_id('traefik@node'), action='set-route', @@ -26,7 +26,7 @@ response = agent.tasks.run( 'url': 'http://127.0.0.1:' + os.environ["TCP_PORT"], 'http2https': False, 'lets_encrypt': False, - 'path': '/kickstart', + 'path': '/sogo', }, ) diff --git a/imageroot/actions/configure-module/80start_services b/imageroot/actions/configure-module/80start_services index 8aed691..8555313 100755 --- a/imageroot/actions/configure-module/80start_services +++ b/imageroot/actions/configure-module/80start_services @@ -9,4 +9,4 @@ touch smarthost.env -systemctl --user enable --now kickstart.service +systemctl --user enable --now sogo.service diff --git a/imageroot/actions/configure-module/validate-input.json b/imageroot/actions/configure-module/validate-input.json index e441099..545f363 100644 --- a/imageroot/actions/configure-module/validate-input.json +++ b/imageroot/actions/configure-module/validate-input.json @@ -1,8 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "configure-module input", - "$id": "http://schema.nethserver.org/kickstart/configure-module-input.json", - "description": "Configure kickstart", + "$id": "http://schema.nethserver.org/sogo/configure-module-input.json", + "description": "Configure sogo", "examples": [], "type": "object" } \ No newline at end of file diff --git a/imageroot/actions/get-configuration/validate-output.json b/imageroot/actions/get-configuration/validate-output.json index 8188b8c..e28420f 100644 --- a/imageroot/actions/get-configuration/validate-output.json +++ b/imageroot/actions/get-configuration/validate-output.json @@ -1,8 +1,8 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "get-configuration output", - "$id": "http://schema.nethserver.org/kickstart/get-configuration-output.json", - "description": "Get kickstart configuration", + "$id": "http://schema.nethserver.org/sogo/get-configuration-output.json", + "description": "Get sogo configuration", "examples": [], "type": "object" } \ No newline at end of file diff --git a/imageroot/bin/discover-smarthost b/imageroot/bin/discover-smarthost index 75ba733..da3a22b 100755 --- a/imageroot/bin/discover-smarthost +++ b/imageroot/bin/discover-smarthost @@ -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 sogo: 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) diff --git a/imageroot/events/smarthost-changed/10reload_services b/imageroot/events/smarthost-changed/10reload_services index 2132b78..a01ad88 100755 --- a/imageroot/events/smarthost-changed/10reload_services +++ b/imageroot/events/smarthost-changed/10reload_services @@ -7,4 +7,4 @@ set -e -systemctl --user try-reload-or-restart kickstart.service +systemctl --user try-reload-or-restart sogo.service diff --git a/imageroot/systemd/user/kickstart.service b/imageroot/systemd/user/sogo.service similarity index 58% rename from imageroot/systemd/user/kickstart.service rename to imageroot/systemd/user/sogo.service index dfcdce8..ac13329 100644 --- a/imageroot/systemd/user/kickstart.service +++ b/imageroot/systemd/user/sogo.service @@ -4,31 +4,31 @@ # # -# This systemd unit starts a kickstart instance using Podman. +# This systemd unit starts a sogo instance using Podman. # Most parts of this file come from podman-generate-systemd. # [Unit] -Description=kickstart server +Description=sogo server [Service] Environment=PODMAN_SYSTEMD_UNIT=%n EnvironmentFile=%S/state/environment WorkingDirectory=%S/state Restart=always -ExecStartPre=/bin/rm -f %t/kickstart.pid %t/kickstart.ctr-id +ExecStartPre=/bin/rm -f %t/sogo.pid %t/sogo.ctr-id ExecStartPre=-runagent discover-smarthost ExecStart=/usr/bin/podman run \ --detach \ - --conmon-pidfile=%t/kickstart.pid \ - --cidfile=%t/kickstart.ctr-id \ + --conmon-pidfile=%t/sogo.pid \ + --cidfile=%t/sogo.ctr-id \ --cgroups=no-conmon \ --replace --name=%N \ --publish=127.0.0.1:${TCP_PORT}:8080 \ --env-file=smarthost.env \ ${ECHO_SERVER_IMAGE} -ExecStop=/usr/bin/podman stop --ignore --cidfile %t/kickstart.ctr-id -t 10 -ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/kickstart.ctr-id -PIDFile=%t/kickstart.pid +ExecStop=/usr/bin/podman stop --ignore --cidfile %t/sogo.ctr-id -t 10 +ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/sogo.ctr-id +PIDFile=%t/sogo.pid Type=forking [Install] diff --git a/tests/kickstart.robot b/tests/sogo.robot similarity index 76% rename from tests/kickstart.robot rename to tests/sogo.robot index e1984f0..a1bcff0 100644 --- a/tests/kickstart.robot +++ b/tests/sogo.robot @@ -2,24 +2,24 @@ Library SSHLibrary *** Test Cases *** -Check if kickstart is installed correctly +Check if sogo is installed correctly ${output} ${rc} = Execute Command add-module ${IMAGE_URL} 1 ... return_rc=True Should Be Equal As Integers ${rc} 0 &{output} = Evaluate ${output} Set Suite Variable ${module_id} ${output.module_id} -Check if kickstart can be configured +Check if sogo can be configured ${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{}' ... return_rc=True return_stdout=False Should Be Equal As Integers ${rc} 0 -Check if kickstart works as expected - ${rc} = Execute Command curl -f http://127.0.0.1/kickstart/ +Check if sogo works as expected + ${rc} = Execute Command curl -f http://127.0.0.1/sogo/ ... return_rc=True return_stdout=False Should Be Equal As Integers ${rc} 0 -Check if kickstart is removed correctly +Check if sogo is removed correctly ${rc} = Execute Command remove-module --no-preserve ${module_id} ... return_rc=True return_stdout=False Should Be Equal As Integers ${rc} 0 diff --git a/ui/README.md b/ui/README.md index 4400e3b..7f2c312 100644 --- a/ui/README.md +++ b/ui/README.md @@ -1,3 +1,3 @@ -# NS8 kickstart UI development +# NS8 sogo UI development -To develop kickstart UI please refer to [this section of the Developer manual](https://nethserver.github.io/ns8-core/ui/modules/#module-ui-development). +To develop sogo UI please refer to [this section of the Developer manual](https://nethserver.github.io/ns8-core/ui/modules/#module-ui-development). diff --git a/ui/public/metadata.json b/ui/public/metadata.json index 305a6f5..7c15b22 100644 --- a/ui/public/metadata.json +++ b/ui/public/metadata.json @@ -1,7 +1,7 @@ { - "name": "kickstart", + "name": "sogo", "description": { - "en": "My kickstart module" + "en": "My sogo module" }, "categories": [], "authors": [ @@ -11,9 +11,9 @@ } ], "docs": { - "documentation_url": "https://docs.kickstart.com/", + "documentation_url": "https://docs.sogo.com/", "bug_url": "https://github.com/NethServer/dev", - "code_url": "https://github.com/author/ns8-kickstart" + "code_url": "https://github.com/author/ns8-sogo" }, - "source": "ghcr.io/nethserver/kickstart" + "source": "ghcr.io/nethserver/sogo" }