Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hostname format validation and add new translations #6

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ To uninstall the instance:

remove-module --no-preserve kickstart1

## Update

To Update the instance:

api-cli run update-module --data '{"module_url":"ghcr.io/nethserver/kickstart:latest","instances":["kickstart1"],"force":true}'

## Smarthost setting discovery

Some configuration settings, like the smarthost setup, are not part of the
Expand Down Expand Up @@ -123,26 +129,21 @@ on the root terminal
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
d8df02bf6f4a docker.io/library/postgres:15.5-alpine3.19 --character-set-s... 9 minutes ago Up 9 minutes 127.0.0.1:20015->80/tcp postgresql-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
```

you can see what environment variable is inside the container
```
podman exec kickstart-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_IMAGE=docker.io/mariadb:10.11.5
MARIADB_DB_TYPE=mysql
container=podman
NGINX_VERSION=1.24.0
PKG_RELEASE=1
NJS_VERSION=0.7.12
MARIADB_DB_USER=kickstart
MARIADB_DB_PASSWORD=kickstart
MARIADB_DB_PORT=3306
NGINX_IMAGE=docker.io/nginx:stable-alpine3.17
CONFIG_DATABASE_URI="postgresql://postgres:Nethesis,[email protected]:5432/toto"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/root
```

Expand Down
2 changes: 1 addition & 1 deletion build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ buildah config --entrypoint=/ \
--label="org.nethserver.authorizations=traefik@node:routeadm" \
--label="org.nethserver.tcp-ports-demand=1" \
--label="org.nethserver.rootfull=0" \
--label="org.nethserver.images=docker.io/mariadb:10.11.5 docker.io/nginx:stable-alpine3.17" \
--label="org.nethserver.images=docker.io/postgres:15.5-alpine3.19 docker.io/nginx:stable-alpine3.17" \
"${container}"
# Commit the image
buildah commit "${container}" "${repobase}/${reponame}"
Expand Down
3 changes: 2 additions & 1 deletion imageroot/actions/configure-module/validate-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"host": {
"type": "string",
"description": "Host name for the application, like 'kickstart.domain.org'",
"format": "idn-hostname"
"format": "hostname",
"pattern": "\\."
},
"lets_encrypt": {
"type": "boolean",
Expand Down
48 changes: 22 additions & 26 deletions imageroot/actions/restore-module/40restore_database
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,30 @@
set -e -o pipefail
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
#do the bash file to restore and exit once done
cat - >initdb.d/zz_kickstart_restore.sh <<'EOS'
# Print additional information:
mysql --version
# The script is sourced, override entrypoint args and exit:
set -- true
mkdir -vp restore
cat - >restore/kickstart_restore.sh <<'EOS'
# Read dump file from standard input:
pg_restore --no-owner --no-privileges -U postgres -d kickstart
ec=$?
docker_temp_server_stop
exit 0
exit $ec
EOS

# once we exit we remove initdb.d
trap 'rm -rfv initdb.d/' EXIT
# Override the image /docker-entrypoint-initdb.d contents, to restore the
# DB dump file. The container will be stopped at the end

# we start a container to initiate a database and load the dump
# at the end of kickstart_restore.sh the dump is loaded and
# we exit the container
podman run \
--rm \
--interactive \
--network=none \
--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 \
--replace --name=restore_db \
${MARIADB_IMAGE}
--rm \
--interactive \
--network=none \
--volume=./restore:/docker-entrypoint-initdb.d/:Z \
--volume=postgres-data:/var/lib/postgresql/data:Z \
--replace --name=restore_db \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=Nethesis,1234 \
--env POSTGRES_DB=kickstart \
--env TZ=UTC \
"${POSTGRES_IMAGE}" < kickstart.pg_dump

# If the restore is successful, clean up:
rm -rfv restore/ kickstart.pg_dump
4 changes: 2 additions & 2 deletions imageroot/actions/restore-module/50traefik
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ request = json.load(sys.stdin)
renv = request['environment']

configure_retval = agent.tasks.run(agent_id=os.environ['AGENT_ID'], action='configure-module', data={
"lets_encrypt": renv["TRAEFIK_LETS_ENCRYPT"],
"lets_encrypt": renv["TRAEFIK_LETS_ENCRYPT"] == "True",
"host": renv["TRAEFIK_HOST"],
"http2https": renv["TRAEFIK_HTTP2HTTPS"],
"http2https": renv["TRAEFIK_HTTP2HTTPS"] == "True",
})
agent.assert_exp(configure_retval['exit_code'] == 0, "The configure-module subtask failed!")
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 kickstart.pg_dump
14 changes: 2 additions & 12 deletions imageroot/bin/module-dump-state
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,5 @@

set -e

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

podman exec mariadb-app mysqldump \
--databases kickstart \
--default-character-set=utf8mb4 \
--skip-dump-date \
--ignore-table=mysql.event \
--single-transaction \
--quick \
--add-drop-table > kickstart.sql
echo "Dumping kickstart postgres database"
podman exec postgresql-app pg_dump -U postgres --format=c kickstart > kickstart.pg_dump
13 changes: 4 additions & 9 deletions imageroot/systemd/user/kickstart-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[Unit]
Description=Podman kickstart-app.service
BindsTo=kickstart.service
After=kickstart.service mariadb-app.service
After=kickstart.service postgresql-app.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Expand All @@ -22,14 +22,9 @@ ExecStart=/usr/bin/podman run --conmon-pidfile %t/kickstart-app.pid \
--cidfile %t/kickstart-app.ctr-id --cgroups=no-conmon \
--pod-id-file %t/kickstart.pod-id --replace -d --name kickstart-app \
--volume kickstart-app:/var/www/html/:Z \
--volume ./tmp:/tmp:Z \
--env=MARIADB_* \
--env MARIADB_DB_TYPE=mysql \
--env MARIADB_DB_HOST=127.0.0.1 \
--env MARIADB_DB_PORT=3306 \
--env MARIADB_DB_USER=kickstart \
--env MARIADB_DB_PASSWORD=kickstart \
--env MARIADB_DB_NAME=kickstart \
--volume ./config:/tmp:Z \
--env=NGINX_* \
--env 'CONFIG_DATABASE_URI="postgresql://postgres:Nethesis,[email protected]:5432/kickstart"' \
${NGINX_IMAGE}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/kickstart-app.ctr-id -t 10
ExecReload=/usr/bin/podman kill -s HUP kickstart-app
Expand Down
4 changes: 2 additions & 2 deletions imageroot/systemd/user/kickstart.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

[Unit]
Description=Podman kickstart.service
Requires=mariadb-app.service kickstart-app.service
Before=mariadb-app.service kickstart-app.service
Requires=postgresql-app.service kickstart-app.service
Before=postgresql-app.service kickstart-app.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Expand Down
40 changes: 0 additions & 40 deletions imageroot/systemd/user/mariadb-app.service

This file was deleted.

39 changes: 39 additions & 0 deletions imageroot/systemd/user/postgresql-app.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (C) 2022 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

[Unit]
Description=Podman postgresql-app.service
BindsTo=kickstart.service
After=kickstart.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
# EnvironmentFile=%S/state/secrets/passwords.secret
Restart=always
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/postgresql-app.pid %t/postgresql-app.ctr-id
ExecStartPre=/bin/mkdir -p %S/state/restore/
ExecStart=/usr/bin/podman run --conmon-pidfile %t/postgresql-app.pid \
--cidfile %t/postgresql-app.ctr-id --cgroups=no-conmon \
--pod-id-file %t/kickstart.pod-id --replace -d --name postgresql-app \
--env-file=%S/state/environment \
--volume postgres-data:/var/lib/postgresql/data:Z \
--volume %S/state/restore/:/docker-entrypoint-initdb.d/:Z \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=Nethesis,1234 \
--env POSTGRES_DB=kickstart \
--env TZ=UTC \
${POSTGRES_IMAGE}
ExecStartPost=/usr/bin/bash -c "while ! podman exec postgresql-app psql -U postgres -d kickstart ; do sleep 5 ; done"
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/postgresql-app.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/postgresql-app.ctr-id
ExecReload=/usr/bin/podman kill -s HUP postgresql-app
SyslogIdentifier=%u
PIDFile=%t/postgresql-app.pid
Type=forking

[Install]
WantedBy=default.target
4 changes: 3 additions & 1 deletion ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"advanced": "Advanced",
"configuring": "Configuring",
"instance_configuration": "Configure kickstart",
"domain_already_used_in_traefik": "Domain already used in traefik"
"domain_already_used_in_traefik": "Domain already used in traefik",
"host_pattern": "Must be a valid fully qualified domain name",
"host_format": "Must be a valid fully qualified domain name"
},
"about": {
"title": "About"
Expand Down
Loading
Loading