-
-
Notifications
You must be signed in to change notification settings - Fork 247
/
raspbian-installer.sh
109 lines (77 loc) · 2.07 KB
/
raspbian-installer.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# This script is meant for a quick and easy setup of homebridge/homebridge on Raspberry Pi OS
# It should be executed on a fresh install of Raspberry Pi OS 11 Lite only!
#
set -e
INSTALL_DIR=$HOME/homebridge
ARCH=$(uname -m)
. /etc/os-release
LP="[homebridge/homebridge installer]"
# Check OS
if [ "$VERSION_ID" = "11" ]; then
echo "$LP Installing on $PRETTY_NAME..."
else
echo "$LP ERROR: $PRETTY_NAME is not supported"
exit 0
fi
echo "$LP Installing Docker..."
# Step 1: Install Docker
sudo apt-get update
sudo apt-get -y install docker.io docker-compose
sudo usermod -aG docker $USER
echo "$LP Docker Installed"
# Step 3: Create Docker Compose Manifest
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
echo "$LP Created $INSTALL_DIR"
PGID=$(id -g)
PUID=$(id -u)
cat >$INSTALL_DIR/docker-compose.yml <<EOL
version: '2'
services:
homebridge:
image: homebridge/homebridge:latest
restart: always
network_mode: host
volumes:
- ./volumes/homebridge:/homebridge
logging:
driver: json-file
options:
max-size: "10mb"
max-file: "1"
environment:
- PGID=$PGID
- PUID=$PUID
EOL
echo "$LP Created $INSTALL_DIR/docker-compose.yml"
# Step 4: Pull Docker Image
echo "$LP Pulling Homebridge Docker image (this may take up to 20 minutes)..."
sudo docker-compose pull
# Step 5: Start Container
echo "$LP Starting Homebridge Docker container..."
sudo docker-compose up -d
# Step 6: Wait for config ui to come up
echo "$LP Waiting for Homebridge to start..."
until $(curl --output /dev/null --silent --head --fail http://localhost:8581); do
printf '.'
sleep 5
done
echo
# Step 7: Success
IP=$(hostname -I)
echo "$LP"
echo "$LP Homebridge Installation Complete!"
echo "$LP You can access the Homebridge UI (homebridge/homebridge-config-ui-x) via:"
echo "$LP"
for ip in $IP; do
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$LP http://$ip:8581"
else
echo "$LP http://[$ip]:8581"
fi
done
echo "$LP"
echo "$LP Installed to: $INSTALL_DIR"
echo "$LP Thanks for installing homebridge/homebridge!"