Publish add-on 0.1.3
From kidtime-server e99d2a801255d4ac1bf5100cb3d6b1080d79f371
This commit is contained in:
1 parent
540fc6d5bd
commit
82e0df5072
4 files changed
+51
-129
No files matched your search
+50
-128
@@ -20,7 +20,24 @@ failed port makes the add-on stop with a clear line in its log.
|
||||
|
||||
The add-on uses the host network, so these ports are open on the Home Assistant
|
||||
machine itself. Do not run another KidTime server on the same network at the
|
||||
same time.
|
||||
same time: both would claim `kidtime.local`.
|
||||
|
||||
## Your data and the certificate
|
||||
|
||||
The add-on keeps everything in its config folder (the folder ending in
|
||||
`_kidtime` in the `app_configs` share, older versions: `addon_configs`):
|
||||
|
||||
| Folder | Holds |
|
||||
| ---------- | --------------------------------------------- |
|
||||
| `db` | the database (`db.sqlite`) |
|
||||
| `certs` | the TLS certificate and key |
|
||||
| `secrets` | the JWT secret |
|
||||
| `client` | the client installers used for updates |
|
||||
|
||||
On its first start the add-on creates a new server with its own certificate.
|
||||
Every provisioned device remembers that certificate and rejects a server that
|
||||
shows a different one. Losing `certs` therefore means setting up every device
|
||||
again, so keep a backup of the config folder.
|
||||
|
||||
## Backups contain secrets
|
||||
|
||||
@@ -31,120 +48,7 @@ devices and sign in as an admin session. Store backups privately and do not shar
|
||||
them. The add-on is stopped while a backup runs (cold backup), so the database is
|
||||
copied consistently.
|
||||
|
||||
## Moving your data
|
||||
|
||||
You can move the Windows server's data into this add-on by copying its folders.
|
||||
The same copy is also your backup and restore method. With the same certificate,
|
||||
key and database, the kids' devices reconnect without being set up again.
|
||||
|
||||
The certificate is the important part. Every provisioned device remembers the
|
||||
server's certificate and rejects a server that shows a different one. If the
|
||||
add-on's config folder is empty when it starts, it creates a brand-new server
|
||||
with a new certificate, so the copy, and the hash comparison of `server.pem`,
|
||||
`server.key` and `jwt.secret`, must be finished before the first start. Follow
|
||||
the order below.
|
||||
|
||||
**Never start the add-on to make its config folder appear.** It would start with
|
||||
a new certificate on your network. Create the folder by hand instead (step 4).
|
||||
|
||||
### Where the Windows data lives
|
||||
|
||||
On this machine the Windows server keeps its data in `server\data` of the
|
||||
KidTime project (`D:\dev\kids-time\server\data`), as set in
|
||||
`server\.localtest\config.yaml`. Inside it are four folders:
|
||||
|
||||
| Folder | Holds |
|
||||
| ---------- | --------------------------------------------- |
|
||||
| `db` | the database (`db.sqlite`) |
|
||||
| `certs` | the TLS certificate and key |
|
||||
| `secrets` | the JWT secret |
|
||||
| `client` | the client installers used for updates |
|
||||
|
||||
Ignore the loose `db.sqlite`, `db.sqlite-shm` and `db.sqlite-wal` files at the top
|
||||
of `server\data`. They are leftovers the server does not use; the real database is
|
||||
`db\db.sqlite`. Do not copy them.
|
||||
|
||||
### Rehearse first
|
||||
|
||||
Before you touch the Green, run `scripts\addon-rehearse.ps1` on the PC. It does
|
||||
the same move on a throwaway copy, on an isolated network, and shows PASS or FAIL
|
||||
for each check. All checks must pass.
|
||||
|
||||
### Steps
|
||||
|
||||
1. **Stop the Windows server cleanly** (stop the service or process, do not kill
|
||||
it), so SQLite writes everything to disk. Also turn off its auto-start while
|
||||
the add-on is in use: both servers claim `kidtime.local`, so they must never
|
||||
run together. If you see `db.sqlite-wal` or `db.sqlite-shm` files inside `db`,
|
||||
copy those too.
|
||||
2. **Make an untouched safety copy.** Copy the whole `server\data` folder to a
|
||||
safe place, for example `server\data-safe`. Never edit it afterwards. This is
|
||||
your rollback.
|
||||
3. **Install the add-on, but do not start it.** Turn auto-start and watchdog off
|
||||
for now.
|
||||
4. **Open the add-on's config folder** from your PC through the Samba or SSH
|
||||
add-on. It is the folder ending in `_kidtime` in the `app_configs` share
|
||||
(older versions: `addon_configs`). Home Assistant may only create this folder
|
||||
when the add-on first starts, so it may not exist yet. Do not start the
|
||||
add-on to find out. If the folder is missing, create it by hand, named
|
||||
`<id>_kidtime`. The add-on's slug is `<id>_kidtime`, where `<id>` is the
|
||||
first 8 hex characters of the SHA-1 of the repository URL, lowercased, exactly
|
||||
as you entered it in Home Assistant (this is how Supervisor derives it; the
|
||||
slug is also shown in the add-on's details page or its URL, for example
|
||||
`abcd1234_kidtime`). A repository added under `/addons` instead gets the slug
|
||||
`local_kidtime`. That Home Assistant accepts and uses a hand-made folder is
|
||||
to be confirmed on the Green (plan Task 6); this has not been verified.
|
||||
5. **Copy the four folders in:** `db`, `certs`, `secrets` and `client`, so that
|
||||
you end up with `db\db.sqlite`, `certs\server.pem`, `certs\server.key`,
|
||||
`secrets\jwt.secret` and `client\...` directly inside the add-on's config
|
||||
folder. Copy from the safety copy or from `server\data`, as long as the
|
||||
Windows server stays stopped.
|
||||
6. **Compare the hashes before the first start.** In PowerShell, from the
|
||||
Windows source folder and then from the add-on's config folder (a network
|
||||
path through Samba), run:
|
||||
|
||||
```powershell
|
||||
Get-FileHash -Algorithm SHA256 certs\server.pem, certs\server.key, secrets\jwt.secret | Select-Object Hash, Path
|
||||
```
|
||||
|
||||
The three hashes must be identical in both places. If any hash differs, or
|
||||
any of the three files is missing, **do not start the add-on**. Copy again
|
||||
and compare again.
|
||||
7. **Start the add-on for the first time** and open its log. You should see
|
||||
"Certificates loaded". If you see "Certificates not found, generating new
|
||||
ones", the copy went to the wrong place: stop the add-on at once and follow
|
||||
"If the add-on generated a new certificate" below, because the kids' devices
|
||||
would reject the new certificate.
|
||||
8. Check that the admin page opens and a kid's device reconnects.
|
||||
9. **Turn auto-start (and watchdog) on** for the add-on, now that the move works.
|
||||
|
||||
The stored installer paths inside the database are Windows paths. The server
|
||||
finds installers by file name inside the `client` folder, so this works without
|
||||
changing the database.
|
||||
|
||||
### If the add-on generated a new certificate
|
||||
|
||||
Stop the add-on. In its config folder, delete everything inside all four folders
|
||||
(`db`, `certs`, `secrets` and `client`), including any `-wal` and `-shm` files in
|
||||
`db`, because the add-on has already created a new empty database. Then copy all
|
||||
four folders in again from the safety copy, compare the hashes (step 6) and
|
||||
start it.
|
||||
|
||||
### Rolling back
|
||||
|
||||
Stop the add-on and start the Windows server on its untouched safety copy (point
|
||||
its configuration at it, or put it back as `server\data`). Usage recorded on the
|
||||
add-on in the meantime is lost, which is acceptable for a test.
|
||||
|
||||
Also turn **Start on boot** and the watchdog off for the add-on, or uninstall it
|
||||
while keeping its data. Otherwise a reboot of the Green starts it again beside
|
||||
the Windows server, and both claim `kidtime.local`.
|
||||
|
||||
The Green's database has diverged from the Windows one by then. On any later
|
||||
re-migration, replace it with the data you copy in; never reuse the Green's old
|
||||
database.
|
||||
|
||||
### Do not change the repository URL
|
||||
## Do not change the repository URL
|
||||
|
||||
In Home Assistant, add the repository
|
||||
`https://git.nc.kreapptivo.de/KidTime/home-assistant-addon`. It is
|
||||
@@ -155,22 +59,40 @@ an account or a registry login.
|
||||
The repository URL you entered in Home Assistant, including any `#branch`, is
|
||||
the add-on's identity. Supervisor's repository id is the first 8 hex characters
|
||||
of the SHA-1 of the lowercased URL as entered, and the slug is `<id>_kidtime`.
|
||||
Changing the URL, adding `#branch` or switching to the `/addons` fallback
|
||||
(`local_kidtime`) gives a different add-on with an empty config folder, which
|
||||
would generate a new certificate if started. So do not change the URL.
|
||||
Changing the URL or adding `#branch` gives a different add-on with an empty
|
||||
config folder, which would generate a new certificate when started. So do not
|
||||
change the URL.
|
||||
|
||||
If you must change it, treat it as a fresh install: install the new entry
|
||||
without starting it, copy the four folders from the old `<old-id>_kidtime`
|
||||
folder, compare the hashes (step 6), start the new one, and only then remove the
|
||||
old entry.
|
||||
If you must change it, move the data over by hand (see "Copying the data into
|
||||
a new install" below) from the old `<old-id>_kidtime` folder, and remove the
|
||||
old entry only after the new one runs.
|
||||
|
||||
### Uninstalling deletes the certificate
|
||||
## Uninstalling deletes the certificate
|
||||
|
||||
When you uninstall the add-on, Home Assistant asks whether to delete its data. If
|
||||
you let it, the certificate, key and database are gone, and a new certificate
|
||||
would be generated on the next start. Every device would then reject the
|
||||
server. Keep an up-to-date copy of the four folders before uninstalling. To
|
||||
recover, reinstall the add-on without starting it, copy the four folders back in
|
||||
from a backup (a copy of the folders or a Home Assistant backup), compare the
|
||||
hashes, and then start it. Home Assistant backups contain the TLS key and JWT
|
||||
secret, so store them privately.
|
||||
server. Keep an up-to-date copy of the four folders, or a Home Assistant backup,
|
||||
before uninstalling. To recover, restore the add-on from the Home Assistant
|
||||
backup, or reinstall it and copy the folders back in by hand.
|
||||
|
||||
## Copying the data into a new install
|
||||
|
||||
Home Assistant may create the config folder only on the add-on's first start,
|
||||
and that start generates a new certificate. Copy the data in afterwards:
|
||||
|
||||
1. Stop the old add-on (or keep it uninstalled) and leave it stopped, so that
|
||||
only one server claims `kidtime.local`.
|
||||
2. Install the new add-on, turn off "Start on boot" and the watchdog, start it
|
||||
once and stop it again. The kids' devices reject its new certificate for that
|
||||
moment; they keep the one they know.
|
||||
3. Delete everything inside its config folder: `db`, `certs`, `secrets` and
|
||||
`client`, including any `-wal` and `-shm` files in `db`.
|
||||
4. Copy the four folders in from the old folder or your copy. Include the
|
||||
`-wal` and `-shm` files next to `db.sqlite`.
|
||||
5. Check that `certs/server.pem`, `certs/server.key` and `secrets/jwt.secret`
|
||||
have the same SHA-256 hashes as the source (for example with `sha256sum` in
|
||||
the Home Assistant terminal).
|
||||
6. Start the add-on. Its log must say "Certificates loaded"; if it says
|
||||
"Certificates not found, generating new ones", stop it and copy again.
|
||||
7. Turn "Start on boot" and the watchdog back on.
|
||||
Reference in new issue
Block a user