-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
86 lines (69 loc) · 2.75 KB
/
install.sh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Update package index
echo "Updating package index..."
sudo apt update
# Install prerequisites
echo "Installing prerequisites..."
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
# Add Docker’s official GPG key
echo "Adding Docker's GPG key..."
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker repository
echo "Adding Docker repository..."
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update package index again after adding Docker repository
echo "Updating package index..."
sudo apt update
# Install Docker and Docker Compose
echo "Installing Docker and Docker Compose..."
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose
# Enable and start Docker service
echo "Enabling and starting Docker service..."
sudo systemctl enable docker
sudo systemctl start docker
echo "Installing Chromium Browser"
# Install Chromium Browser
sudo apt-get install chromium-browser
# Set Home Assistant to open on startup
sleep 10 # Wait for 10 seconds to ensure the system is fully up
chromium-browser --kiosk --new-window http://localhost:8123
# Verify Docker installation
echo "Verifying Docker installation..."
docker --version
docker-compose --version
# Create homeassistant directory in the user's home if it doesn't already exist
echo "Creating homeassistant directory..."
mkdir -p ~/homeassistant/
# Create docker-compose.yaml file with specified content
echo "Creating docker-compose.yaml file..."
cat <<EOL > docker-compose.yaml
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- ~/homeassistant/config:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
privileged: true
network_mode: host
EOL
echo "docker-compose.yaml has been created successfully!"
echo "Docker and Docker Compose have been installed, and the docker-compose.yaml file is ready."
echo "Running Home Assistant Installation via Docker Compose"
# Installing Docker Compose
sudo docker-compose up -d
# Display access instructions
echo "=================================================="
echo "Home Assistant Installation Complete!"
echo
echo "To access Home Assistant, open your web browser and go to:"
echo
echo " http://<YOUR_DEVICE_IP>:8123"
echo
echo "Replace <YOUR_DEVICE_IP> with the actual IP address of this device."
echo "To find the IP address, run: ip a"
echo "=================================================="