forked from diyhue/diyHue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
49 lines (42 loc) · 1.82 KB
/
startup.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
#!/bin/bash
if [ -n ${1+x} ]; then
mac=$1
echo -e "\033[33m--MAC given as $mac--\033[0m"
fi
echo -e "\033[33m--Setting up diyHue--\033[0m"
if [ -f "/opt/hue-emulator/export/cert.pem" ]; then
echo -e "\033[33m--Restoring certificate--\033[0m"
cp /opt/hue-emulator/export/cert.pem /opt/hue-emulator/cert.pem
echo -e "\033[33m--Certificate restored--\033[0m"
else
echo -e "\033[33m--Generating certificate--\033[0m"
/opt/hue-emulator/genCert.sh $mac
cp /opt/hue-emulator/cert.pem /opt/hue-emulator/export/cert.pem
echo -e "\033[33m--Certificate created--\033[0m"
fi
if [ -f "/opt/hue-emulator/export/config.json" ]; then
echo -e "\033[33m--Restoring config--\033[0m"
cp /opt/hue-emulator/export/config.json /opt/hue-emulator/config.json
echo -e "\033[33m--Config restored--\033[0m"
else
echo -e "\033[33m--Downloading default config--\033[0m"
curl -o /opt/hue-emulator/config.json https://raw.githubusercontent.com/mariusmotea/diyHue/master/BridgeEmulator/config.json
cp /opt/hue-emulator/config.json /opt/hue-emulator/export/config.json
echo -e "\033[33m--Config downloaded--\033[0m"
fi
cd /opt/hue-emulator
if [ $3=true ]; then
echo -e "\033[33m--Debug set to $3, enabling debug--\033[0m"
sed -i "s|debug = .* #|debug = True # |g" /opt/hue-emulator/HueEmulator3.py
else
echo -e "\033[33m--Debug set to $3, disabling debug--\033[0m"
sed -i "s|debug = .* #|debug = False # |g" /opt/hue-emulator/HueEmulator3.py
fi
echo -e "\033[32m--Startup complete. Open Hue app and search for bridges--\033[0m"
if [ -z $1 -a -z $2 ]; then
echo -e "\033[32m--Starting without provided MAC & IP--\033[0m"
exec python3 /opt/hue-emulator/HueEmulator3.py
else
echo -e "\033[32m--Starting with provided MAC & IP--\033[0m"
exec python3 /opt/hue-emulator/HueEmulator3.py $1 $2
fi