forked from Glavin001/resin-homebridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·26 lines (23 loc) · 832 Bytes
/
setup.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
#!/usr/bin/env bash
WORKING_DIR="/usr/src/app"
HOMEBRIDGE_DIR="/data/.homebridge/"
KEEP_CONFIG=${KEEP_CONFIG:-no}
cd "$WORKING_DIR"
# Setup Homebridge
if [ -d "$HOMEBRIDGE_DIR" ]; then
# Exists
echo "Homebridge is already configured at \"$HOMEBRIDGE_DIR\"."
if [ "$KEEP_CONFIG" = "yes" ]; then
echo "KEEP_CONFIG=yes, Run \"Purge Data\" and then \"Reboot\" action to reset to default configuration."
else
echo "KEEP_CONFIG=no, Replacing $HOMEBRIDGE_DIR/config.json with .homebridge/config.json"
cp .homebridge/config.json "$HOMEBRIDGE_DIR"
fi
else
# Does not exist
echo "Homebridge is not configured."
echo "Creating Homebridge directory at \"$HOMEBRIDGE_DIR\"."
mkdir -p "$HOMEBRIDGE_DIR"
echo "Copying Homebridge configuration"
cp .homebridge/* "$HOMEBRIDGE_DIR"
fi