3.1 KiB
LXC installation and update
This document describes the supported Debian/Ubuntu systemd deployment used for LXC testing.
First installation
Unpack the source archive inside the container and run:
cd gree-controller
chmod +x scripts/*.sh
sudo ./scripts/install.sh
The installer:
- installs required build packages when missing,
- installs stable Rust with rustup when Cargo is unavailable,
- runs
cargo test --all-targets, - builds
target/release/gree-controller, - creates the
gree-controllersystem user/group, - creates
/var/lib/gree-controller,/opt/gree-controllerand/var/backups/gree-controller, - installs the systemd unit,
- creates
/etc/gree-controller.envonly when it does not already exist, - enables/restarts the service,
- verifies
GET /api/health.
Installed state is intentionally outside the extracted source directory:
/opt/gree-controller/gree-controller installed binary
/etc/gree-controller.env persistent configuration/secrets
/var/lib/gree-controller/gree-controller.db persistent SQLite database
/var/backups/gree-controller/ update backups
/etc/systemd/system/gree-controller.service systemd service
The default installation starts in simulator mode. Change GREE_CONTROLLER_SIMULATE=false and GREE_CONTROLLER_AUTO_SEED=false in /etc/gree-controller.env when moving to physical units, then restart the service.
Update
Unpack a newer source archive and run from that new directory:
sudo ./scripts/update.sh
The update workflow is designed to minimize downtime and preserve the database:
- build dependencies/Rust are checked,
- tests run while the currently installed controller stays online,
- the new release binary is built while the old service stays online,
- the service is stopped,
- the installed binary, service unit, environment file and SQLite database are copied to
/var/backups/gree-controller/<UTC timestamp>/, - the new binary/unit is installed,
- systemd starts the new version,
/api/healthis checked,- on failure the old binary, unit and database are restored automatically.
The updater does not overwrite /etc/gree-controller.env during a successful update.
Use --skip-tests only for deliberate fast testing:
sudo ./scripts/update.sh --skip-tests
Service helper
./scripts/service.sh status
./scripts/service.sh health
./scripts/service.sh logs
sudo ./scripts/service.sh restart
sudo ./scripts/service.sh stop
sudo ./scripts/service.sh start
Equivalent native commands remain available:
systemctl status gree-controller
journalctl -u gree-controller -f
Configuration
Edit:
/etc/gree-controller.env
and restart:
sudo ./scripts/service.sh restart
Do not store controller or Home Assistant secrets in the source tree.
Database and SQL layout
Runtime persistence uses SQLite. All schema definitions and SQL statements in the Rust application are centralized in:
src/queries.rs
src/db.rs contains connection/transaction logic and maps database rows to Rust domain models, but it does not embed SQL statements.