This commit is contained in:
Mateusz Gruszczyński
2026-08-24 23:11:41 +02:00
parent 4ab878d587
commit 76a6f050ae
24 changed files with 600 additions and 108 deletions
+10 -4
View File
@@ -93,10 +93,13 @@ read_env_value() {
}
health_url() {
local bind port
local bind port base
bind="$(read_env_value GREE_CONTROLLER_BIND '0.0.0.0:8787')"
port="${bind##*:}"
printf 'http://127.0.0.1:%s/api/health' "$port"
base="$(read_env_value GREE_CONTROLLER_BASE_PATH '')"
base="/${base#/}"; base="${base%/}"
[[ "$base" == "/" ]] && base=""
printf 'http://127.0.0.1:%s%s/api/health' "$port" "$base"
}
database_path() {
@@ -109,11 +112,14 @@ database_path() {
}
panel_url() {
local bind port ip
local bind port ip base
bind="$(read_env_value GREE_CONTROLLER_BIND '0.0.0.0:8787')"
port="${bind##*:}"
ip="$(hostname -I 2>/dev/null | awk '{print $1}')"
printf 'http://%s:%s' "${ip:-LXC_ADDRESS}" "$port"
base="$(read_env_value GREE_CONTROLLER_BASE_PATH '')"
base="/${base#/}"; base="${base%/}"
[[ "$base" == "/" ]] && base=""
printf 'http://%s:%s%s/' "${ip:-LXC_ADDRESS}" "$port" "$base"
}
wait_for_health() {
+4 -18
View File
@@ -64,31 +64,17 @@ install -o root -g root -m 0755 target/release/gree-controller "$INSTALL_BINARY"
install -o root -g root -m 0644 systemd/gree-controller.service "$SERVICE_FILE"
if [[ ! -f "$ENV_FILE" ]]; then
token="$(od -An -N24 -tx1 /dev/urandom | tr -d ' \n')"
cat > "$ENV_FILE" <<ENV
GREE_CONTROLLER_BIND=0.0.0.0:8787
GREE_CONTROLLER_DATABASE=$DATA_DIR/gree-controller.db
GREE_CONTROLLER_APP_TOKEN=$token
# Empty token intentionally enables trusted-LAN mode without login.
GREE_CONTROLLER_APP_TOKEN=
GREE_CONTROLLER_SIMULATE=false
GREE_CONTROLLER_AUTO_SEED=false
GREE_CONTROLLER_POLL_INTERVAL_SECONDS=15
GREE_CONTROLLER_ZONE_INTERVAL_SECONDS=5
GREE_CONTROLLER_DISCOVERY_TIMEOUT_MS=3000
GREE_CONTROLLER_DISCOVERY_BROADCAST=255.255.255.255:7000
GREE_CONTROLLER_GREE_INTERFACE=
GREE_CONTROLLER_ID=gree-controller
GREE_CONTROLLER_HOUSE_MODE=cool
GREE_CONTROLLER_OUTDOOR_ASSIST_ENABLED=true
RUST_LOG=info,tower_http=info
HA_URL=
HA_TOKEN=
HA_ENTITY_ID=
HA_OUTDOOR_ENTITY_ID=
HA_ALLOW_INVALID_TLS=false
RUST_LOG=gree_controller=info,tower_http=info
ENV
chmod 0600 "$ENV_FILE"
say "Generated administrator token and saved it to $ENV_FILE"
printf 'Administrator token: %s\n' "$token"
say "Created minimal configuration in $ENV_FILE (authentication disabled by default)"
else
say "Preserving existing $ENV_FILE"
fi