forked from snazzybean/roommind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·57 lines (48 loc) · 1.93 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·57 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
#
# RoomMind – Deploy to Home Assistant via SSH
#
# Configuration (in order of priority):
# 1. Command-line args: ./deploy.sh 192.168.1.100 22
# 2. Environment file: .env (copy .env.example to get started)
# 3. Built-in defaults: localhost:22
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Load .env if present
if [[ -f "${SCRIPT_DIR}/.env" ]]; then
# shellcheck source=/dev/null
source "${SCRIPT_DIR}/.env"
fi
HA_IP="${1:-${HA_IP:-localhost}}"
SSH_PORT="${2:-${SSH_PORT:-22}}"
SSH_USER="${SSH_USER:-root}"
REMOTE_CONFIG="${REMOTE_CONFIG:-/config}"
# Suppress macOS resource fork files in tar
export COPYFILE_DISABLE=1
SSH_OPTS="-p ${SSH_PORT} -o StrictHostKeyChecking=no"
[[ -n "${SSH_KEY:-}" ]] && SSH_OPTS="-i ${SSH_KEY} ${SSH_OPTS}"
SSH_CMD="ssh ${SSH_OPTS}"
echo "==> Deploying RoomMind to ${SSH_USER}@${HA_IP}:${SSH_PORT}"
# 1. Build frontend
echo "--- Building frontend ---"
if ! command -v npm >/dev/null 2>&1; then
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# shellcheck source=/dev/null
[[ -s "${NVM_DIR}/nvm.sh" ]] && . "${NVM_DIR}/nvm.sh"
fi
(cd "${SCRIPT_DIR}/frontend" && npm run build --silent)
echo " OK"
# 2. Deploy integration (backend + frontend bundle)
echo "--- Deploying integration ---"
${SSH_CMD} "${SSH_USER}@${HA_IP}" \
"sudo mkdir -p ${REMOTE_CONFIG}/custom_components/roommind && \
sudo find ${REMOTE_CONFIG}/custom_components/roommind -name '__pycache__' -exec rm -rf {} + 2>/dev/null; true"
tar czf - -C "${SCRIPT_DIR}/custom_components/roommind" . | \
${SSH_CMD} "${SSH_USER}@${HA_IP}" "sudo tar xzf - -C ${REMOTE_CONFIG}/custom_components/roommind/"
echo " OK"
echo ""
echo "==> Done! Next steps:"
echo " - Python changes: Settings → Integrations → RoomMind → ⋮ → Reload"
echo " - Frontend changes: Hard-refresh browser (Cmd+Shift+R / Ctrl+Shift+R)"
echo " - WS schema / manifest: Full HA restart (Settings → System → Restart)"