-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
73 lines (60 loc) · 3.48 KB
/
install.sh
File metadata and controls
73 lines (60 loc) · 3.48 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# Ctrlable Voice Assistant — installer
set -euo pipefail
INSTALL_DIR="${1:-/opt/ctrlable-linux-va}"
SERVICE_NAME="ctrlable-voice-assistant"
SERVICE_USER="${SUDO_USER:-$USER}"
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
# ── Checks ────────────────────────────────────────────────────────────────────
[[ $EUID -eq 0 ]] || { echo "Run with sudo: sudo bash install.sh"; exit 1; }
command -v python3 &>/dev/null || { echo "python3 is required"; exit 1; }
PYTHON_VERSION=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
if [[ "$(printf '%s\n' "3.11" "$PYTHON_VERSION" | sort -V | head -1)" != "3.11" ]]; then
echo "Python 3.11+ required (found $PYTHON_VERSION)"
exit 1
fi
echo "Installing Ctrlable Voice Assistant"
echo " Install dir : $INSTALL_DIR"
echo " Service user: $SERVICE_USER"
echo ""
# ── Install directory ─────────────────────────────────────────────────────────
mkdir -p "$INSTALL_DIR/satellites"
chown -R "$SERVICE_USER:$SERVICE_USER" "$INSTALL_DIR"
# ── Copy files ────────────────────────────────────────────────────────────────
cp "$REPO_DIR/run.py" "$REPO_DIR/snapcast_player.py" "$INSTALL_DIR/"
cp -n "$REPO_DIR/satellites/example.env" "$INSTALL_DIR/satellites/example.env" 2>/dev/null || true
install -m 755 "$REPO_DIR/manage.sh" "$INSTALL_DIR/manage.sh"
ln -sf "$INSTALL_DIR/manage.sh" /usr/local/bin/ctrlable-va 2>/dev/null || true
# ── Python virtual environment ────────────────────────────────────────────────
sudo -u "$SERVICE_USER" python3 -m venv "$INSTALL_DIR/venv"
sudo -u "$SERVICE_USER" "$INSTALL_DIR/venv/bin/pip" install --upgrade pip -q
sudo -u "$SERVICE_USER" "$INSTALL_DIR/venv/bin/pip" install \
"git+https://github.com/OHF-Voice/linux-voice-assistant.git" \
python-dotenv \
-q
echo "Dependencies installed"
# ── Systemd template service ──────────────────────────────────────────────────
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}@.service"
sed \
-e "s|__INSTALL_DIR__|$INSTALL_DIR|g" \
-e "s|__USER__|$SERVICE_USER|g" \
"$REPO_DIR/systemd/${SERVICE_NAME}@.service" \
> "$SERVICE_FILE"
systemctl daemon-reload
echo "Systemd template installed: ${SERVICE_NAME}@.service"
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo "Installation complete."
echo ""
echo "Add your first satellite:"
echo ""
echo " sudo ctrlable-va add living-room \\"
echo " --input hw:CARD=USBDevice0,DEV=0 \\"
echo " --output hw:CARD=USBDevice0,DEV=0"
echo ""
echo "Then add each device to Home Assistant:"
echo " Settings → Devices & Services → Add Integration → ESPHome"
echo " Host: $(hostname -I | awk '{print $1}') Port: 6053 (first instance)"
echo ""
echo "List instances: sudo ctrlable-va list"
echo "Follow logs: sudo ctrlable-va logs living-room"