YYP0502 commited on
Commit
881a0ef
·
verified ·
1 Parent(s): f4039a1

Upload start-homeassistant

Browse files
Files changed (1) hide show
  1. scripts/start-homeassistant +13 -13
scripts/start-homeassistant CHANGED
@@ -1,19 +1,19 @@
1
- #!/usr/bin/env bash
2
- set -Eeuo pipefail
3
 
4
  CONFIG_DIR="${HOME_ASSISTANT_CONFIG:-/data/home-assistant}"
5
  CUSTOM_COMPONENT="/opt/ha-custom-components/xiaomi_miot"
6
 
7
- mkdir -p "$CONFIG_DIR/custom_components"
8
- if [[ ! -f "$CONFIG_DIR/configuration.yaml" ]]; then
9
- python3 /usr/local/bin/backup-homeassistant.py restore --config "$CONFIG_DIR" || true
10
  fi
11
 
12
- if [[ ! -d "$CONFIG_DIR/custom_components/xiaomi_miot" ]]; then
13
  cp -a "$CUSTOM_COMPONENT" "$CONFIG_DIR/custom_components/xiaomi_miot"
14
  fi
15
 
16
- if [[ ! -f "$CONFIG_DIR/configuration.yaml" ]]; then
17
  cat > "$CONFIG_DIR/configuration.yaml" <<'YAML'
18
  default_config:
19
 
@@ -22,7 +22,7 @@ http:
22
  YAML
23
  fi
24
 
25
- if [[ -n "${HF_TOKEN:-}" && -n "${BACKUP_REPO_ID:-}" ]]; then
26
  (
27
  while sleep 600; do
28
  python3 /usr/local/bin/backup-homeassistant.py backup --config "$CONFIG_DIR" || true
@@ -34,13 +34,13 @@ else
34
  fi
35
 
36
  cleanup() {
37
- if [[ -n "$BACKUP_PID" ]]; then kill "$BACKUP_PID" 2>/dev/null || true; fi
38
- if [[ -n "${HF_TOKEN:-}" && -n "${BACKUP_REPO_ID:-}" ]]; then
 
 
39
  python3 /usr/local/bin/backup-homeassistant.py backup --config "$CONFIG_DIR" || true
40
  fi
41
  }
42
  trap cleanup EXIT TERM INT
43
 
44
- hass --config "$CONFIG_DIR" --port 7860 &
45
- HA_PID=$!
46
- wait "$HA_PID"
 
1
+ #!/bin/sh
2
+ set -eu
3
 
4
  CONFIG_DIR="${HOME_ASSISTANT_CONFIG:-/data/home-assistant}"
5
  CUSTOM_COMPONENT="/opt/ha-custom-components/xiaomi_miot"
6
 
7
+ mkdir -p "$CONFIG_DIR/custom_components"
8
+ if [ ! -f "$CONFIG_DIR/configuration.yaml" ]; then
9
+ python3 /usr/local/bin/backup-homeassistant.py restore --config "$CONFIG_DIR" || true
10
  fi
11
 
12
+ if [ ! -d "$CONFIG_DIR/custom_components/xiaomi_miot" ]; then
13
  cp -a "$CUSTOM_COMPONENT" "$CONFIG_DIR/custom_components/xiaomi_miot"
14
  fi
15
 
16
+ if [ ! -f "$CONFIG_DIR/configuration.yaml" ]; then
17
  cat > "$CONFIG_DIR/configuration.yaml" <<'YAML'
18
  default_config:
19
 
 
22
  YAML
23
  fi
24
 
25
+ if [ -n "${HF_TOKEN:-}" ] && [ -n "${BACKUP_REPO_ID:-}" ]; then
26
  (
27
  while sleep 600; do
28
  python3 /usr/local/bin/backup-homeassistant.py backup --config "$CONFIG_DIR" || true
 
34
  fi
35
 
36
  cleanup() {
37
+ if [ -n "$BACKUP_PID" ]; then
38
+ kill "$BACKUP_PID" 2>/dev/null || true
39
+ fi
40
+ if [ -n "${HF_TOKEN:-}" ] && [ -n "${BACKUP_REPO_ID:-}" ]; then
41
  python3 /usr/local/bin/backup-homeassistant.py backup --config "$CONFIG_DIR" || true
42
  fi
43
  }
44
  trap cleanup EXIT TERM INT
45
 
46
+ exec hass --config "$CONFIG_DIR" --port 7860