Project

General

Profile

Operations » History » Version 5

Redmine Admin, 10/31/2026 07:25 PM
deploy-publish.sh

1 4 Redmine Admin
*Chapter 5 of the dmz-web documentation · headings are numbered like the cheat sheets · index: [[Wiki]]*
2 1 Redmine Admin
3 4 Redmine Admin
{{>toc}}
4
5
## 5.1 Services
6
7 2 Redmine Admin
```bash
8 1 Redmine Admin
systemctl --user daemon-reload                        # after editing any Quadlet file
9
systemctl --user list-units 'db-*' 'site-*' 'net-*' 'nginx-proxy-manager*'
10
systemctl --user status  db-<name>.service site-<name>.service
11
systemctl --user restart db-<name>.service site-<name>.service
12
journalctl --user -u site-<name>.service -e
13
/usr/libexec/podman/quadlet -dryrun -user             # validate Quadlet syntax
14
```
15
16 4 Redmine Admin
## 5.2 Listing / inspecting
17 1 Redmine Admin
18 2 Redmine Admin
```bash
19 1 Redmine Admin
podman ps -a
20
podman network ls ; podman volume ls ; podman secret ls
21
podman inspect <ctr> --format '{{.ImageName}}'
22
podman inspect <ctr> --format '{{range .Mounts}}{{.Name}} -> {{.Destination}}{{"\n"}}{{end}}'
23
podman inspect <ctr> | jq '.[0].Config.Env'
24
podman logs -f <ctr>
25
podman exec -it <ctr> bash                            # root shell inside, no password
26
```
27
28 4 Redmine Admin
## 5.3 Environment variables inside a container
29 2 Redmine Admin
30 1 Redmine Admin
```bash
31
podman exec <ctr> printenv
32
podman exec <ctr> printenv | grep -iE 'ROOT|PASSWORD|KEY'
33
podman exec <ctr> printenv MYSQL_ROOT_PASSWORD | od -c | tail -3   # reveals a stray trailing \n
34
```
35
36 4 Redmine Admin
## 5.4 Secrets
37 1 Redmine Admin
38 2 Redmine Admin
Injected as env at container start (`Secret=<secret>,type=env,target=VAR`).
39
MariaDB/PostgreSQL only read their `*_PASSWORD` env on **first**
40
initialisation of an empty data dir; afterwards the env var is inert and the
41 1 Redmine Admin
real password is whatever is in the DB.
42
43 2 Redmine Admin
```bash
44 1 Redmine Admin
podman secret inspect --showsecret <secret>
45
podman secret inspect --showsecret --format '{{.SecretData}}' <secret>
46
47
# always create WITHOUT a trailing newline
48
printf '%s' 'VALUE' | podman secret create <secret> -
49
printf '%s' "$(openssl rand -base64 32)" | podman secret create <secret> -
50
51
# replace: rm + create, then restart the consumers
52
podman secret rm <secret> && printf '%s' 'VALUE' | podman secret create <secret> -
53
```
54
55 4 Redmine Admin
## 5.5 Fixing a secret that has a trailing `\n` (legacy WordPress sites)
56 1 Redmine Admin
57 2 Redmine Admin
```bash
58 1 Redmine Admin
cat > ~/tmp/fixpw.sh <<'EOF'
59
ROOTPW="$(printf '%s' "$MYSQL_ROOT_PASSWORD")"   # $(...) strips the trailing \n
60
WPPW="$(printf '%s' "$MYSQL_PASSWORD")"
61
mariadb -uroot -p"$MYSQL_ROOT_PASSWORD" <<SQL
62
ALTER USER 'root'@'localhost' IDENTIFIED BY '$ROOTPW';
63
ALTER USER 'root'@'%'         IDENTIFIED BY '$ROOTPW';
64
ALTER USER 'wordpress'@'%'    IDENTIFIED BY '$WPPW';
65
FLUSH PRIVILEGES;
66
SQL
67
EOF
68
podman exec -i db-<name> sh < ~/tmp/fixpw.sh
69
for s in <name>-db-root-password <name>-db-password; do
70
  v="$(podman secret inspect --showsecret --format '{{.SecretData}}' "$s")"
71
  podman secret rm "$s"; printf '%s' "$v" | podman secret create "$s" -
72
done
73
systemctl --user restart db-<name>.service site-<name>.service   # run back to back with the SQL half
74
```
75
76 4 Redmine Admin
## 5.6 Database engines and version upgrades
77 1 Redmine Admin
78 3 Redmine Admin
Every stack has its own DB container; the engine and version are in the DB unit (`Image=`). Rule
79
for all of them: **dump first, change one `Image=` line in the repo copy, commit, copy the unit,
80 4 Redmine Admin
daemon-reload, restart, check** (§3.1.7 and §3.1.6, same procedure as the Snipe-IT image upgrade in §4.3). Which
81 3 Redmine Admin
of the two cases applies depends on the kind of jump.
82
83
| Engine | Patch / minor (same major) | Major jump |
84
|--------|----------------------------|------------|
85
| MariaDB (WordPress, Snipe-IT) | Change the tag or digest, restart. The data directory is kept; schema upgrades are applied by the server. Dump beforehand. | Never straight on the live volume. 1. Dump all databases. 2. Start the new version as a **scratch** container with an empty volume and restore the dump there. 3. Check the application against it (staging first). 4. Only then switch the real unit. Do not rely on `MARIADB_AUTO_UPGRADE` as the only safety net: it upgrades the system tables on start, but a failed or half-done upgrade cannot be undone without the dump. If you do keep the volume, run `mariadb-upgrade` inside the container once after the start and read its output. |
86
| PostgreSQL (Redmine) | Change the minor tag (e.g. `16.4` → `16.6`), restart. | The data directory format changes: **dump and restore** (`pg_dumpall` or `pg_dump -Fc` per database into a new empty volume under the new major version). Do not just change the tag; the container would refuse to start or, worse, you would be tempted to delete the volume. |
87
| TimescaleDB on PG 16 (PF) | The `timescaledb:<x.y.z>-pg16` tag can move to a newer extension version; after the restart run `ALTER EXTENSION timescaledb UPDATE;` in the PF database (in a fresh session) and check `\dx`. Dump first. | A PostgreSQL major (`-pg16` → `-pg17`) is the dump-and-restore case above, with the Timescale restore steps from `pf-mgmt-cheatsheet.md` (`timescaledb_pre_restore()` / `timescaledb_post_restore()`). |
88
89
A dump that was never restored is not a backup: restore it once into a scratch container and look
90
at the data before you depend on it. Keep the old image tag and the old volume until the new
91
version has run for a few days; then remove them.
92
93 5 Redmine Admin
## 5.7 One root shell for everything — `as-web` and `pf-upgrade.sh` (root)
94
95
Until now a job that needs both identities (root for `deploy-commit.sh`, websvcmaster for `podman` and `systemctl --user`) meant switching users back and forth. Two scripts keep you in the root shell and switch for you. Both are in the repo (`root-bin/`), installed to `/usr/local/sbin/` by `deploy-publish.sh` (root:root 0750) and both **ask before they change anything** they cannot undo by themselves.
96
97
**`as-web`** runs a command as websvcmaster with the rootless environment a console login would have (`HOME`, `XDG_RUNTIME_DIR=/run/user/<uid>`, the user bus), starting in websvcmaster's home:
98
99
```bash
100
as-web                                   # interactive shell as websvcmaster; "exit" returns to root
101
as-web podman ps
102
as-web systemctl --user status site-pf.service
103
as-web bash -c 'cd ~ && podman exec db-pf pg_dump -U pf_user -Fc pf_db > ~/tmp/x.dump'    # redirections need bash -c
104
```
105
106
It refuses when websvcmaster has no user manager running (`loginctl enable-linger websvcmaster`, §0).
107
108
**`pf-upgrade.sh <version>`** is the procedure of the PF sheet §8.3.1 in one go: pre-flight (tarball readable and a PF source, sha256 shown or checked with `-s`, version newer than the unit's, old tree name free) → backup → tarball into `~/deploy` → `apps/pf` kept as `apps/pf-<old>`, unpack, `podman build`, `Image=` in the unit → `deploy-commit.sh` → copy the unit, `daemon-reload`, restart **only** `site-pf`, wait for *healthy* → log tail and `check-sites.sh`. A failed build puts the old tree back and leaves the unit untouched.
109
110
```bash
111
pf-upgrade.sh -n 1.1.6                   # dry run: all checks, every command printed, nothing changed
112
pf-upgrade.sh -s <sha256> 1.1.6          # tarball /root/pf-app-1.1.6.tar.gz (SFTP), stop unless the sha256 matches, ask before each step
113
pf-upgrade.sh -y -B 1.1.6                # no questions, no backup (only when the release says "no schema change")
114
```
115
116
Options: `-t <file>` other tarball path, `-f` same or older version (rebuild / rollback), `-h` help. Rollback: `pf-upgrade.sh -f -t <old tarball> <old version>`, or the manual steps of §8.3.1; when the release notes say the new version stored data the old one cannot read (splits, §8.5.5), restore the dump instead.
117
118
119 1 Redmine Admin
---
120 5 Redmine Admin
_Source: `dmz-web-podman-cheatsheet.md` v1.13 in the `dmz-web-deploy` repo ([[Releases]]). Edit the wiki and the repo copy together._