Skip to content

Instantly share code, notes, and snippets.

@anieto
Forked from 350d/config.json
Last active July 14, 2018 20:31
Show Gist options
  • Select an option

  • Save anieto/a818aba258fb542278e3e7c9e00b10f6 to your computer and use it in GitHub Desktop.

Select an option

Save anieto/a818aba258fb542278e3e7c9e00b10f6 to your computer and use it in GitHub Desktop.
Full install + Systemd Service for Homebridge
{
"bridge": {
"name": "Homebridge",
"username": "{MAC}",
"port": 51826,
"pin": "{PIN}"
},
"description": "This is an example configuration file. You can use this as a template for creating your own configuration file containing devices you actually own.",
"accessories": [],
"platforms": [
{
"platform" : "HomeBridgeControllerLink"
}
]
}
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target
[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
# Adapt this to your specific setup (could be /usr/bin/homebridge)
# See comments below for more information
#ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS
#ExecStart=/opt/node/bin/homebridge $HOMEBRIDGE_OPTS
ExecStart=/opt/node/lib/node_modules/homebridge/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
#!/bin/bash
apt-get update -y
apt-get upgrade -y
apt-get install -y git make
#recommended method for Pi3:
#curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
#apt-get install -y nodejs
#Pi3 + Pi ZERO W experiment:
curl -sL https://gist.githubusercontent.com/anieto/a818aba258fb542278e3e7c9e00b10f6/raw/150a94ce6dbf8b264e09ef7030ce5013187cd9dd/install_nodejs | sudo -E bash -
apt-get install -y libavahi-compat-libdnssd-dev
npm install -g --unsafe-perm homebridge
npm install -g homebridge-controllerlink
#install Homebridge service
curl -sL https://gist.githubusercontent.com/anieto/a818aba258fb542278e3e7c9e00b10f6/raw/150a94ce6dbf8b264e09ef7030ce5013187cd9dd/homebridge_service_install | sudo -E bash -
journalctl -f -u homebridge
#!/bin/bash
useradd -M --system homebridge
usermod -a -G video homebridge
mkdir /var/lib/homebridge
chmod 777 /var/lib/homebridge -R
wget https://gist.githubusercontent.com/anieto/a818aba258fb542278e3e7c9e00b10f6/raw/150a94ce6dbf8b264e09ef7030ce5013187cd9dd/config.json -O /var/lib/homebridge/config.json -q
PIN=$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))-$((1+RANDOM%9))$((1+RANDOM%9))-$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))
sed -i -- "s,{PIN},$(echo $PIN),g" /var/lib/homebridge/config.json
sed -i -- "s,{MAC},$(echo $(cat /sys/class/net/$(ip route show default | awk '/default/ {print $5}')/address) | awk '{print toupper($0)}'),g" /var/lib/homebridge/config.json
wget https://gist.githubusercontent.com/anieto/a818aba258fb542278e3e7c9e00b10f6/raw/150a94ce6dbf8b264e09ef7030ce5013187cd9dd/homebridge -q
wget https://gist.githubusercontent.com/anieto/a818aba258fb542278e3e7c9e00b10f6/raw/150a94ce6dbf8b264e09ef7030ce5013187cd9dd/homebridge.service -O /etc/systemd/system/homebridge.service -q
chmod 777 /var/lib/homebridge -R
systemctl daemon-reload
systemctl enable homebridge
systemctl start homebridge
echo "Your PIN: "$PIN
PICHIP=$(uname -m)
NODEVERSION="8.9.4"
#NODE="$(curl -sL https://nodejs.org/dist/latest | grep $PICHIP'.tar.xz' | cut -d'"' -f2)"
#NODEFOLDER=$(echo $NODE | sed 's/.tar.xz//')
#wget https://nodejs.org/dist/latest/$NODE
NODEFOLDER=node-v$NODEVERSION-linux-$PICHIP
NODETARXZ=$NODEFOLDER.tar.xz
wget https://nodejs.org/dist/v$NODEVERSION/$NODETARXZ
tar xJvf $NODETARXZ
rm $NODETARXZ
rm -R -f /opt/node/
rm /usr/bin/node /usr/sbin/node /sbin/node /sbin/node /usr/local/bin/node /usr/bin/npm /usr/sbin/npm /sbin/npm /usr/local/bin/npm 2> /dev/null;
mkdir -p /opt/node
mv $NODEFOLDER/* /opt/node/
rm -R -f $NODEFOLDER
update-alternatives --install "/usr/bin/node" "node" "/opt/node/bin/node" 1
update-alternatives --install "/usr/bin/npm" "npm" "/opt/node/bin/npm" 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment