Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/350d/c774e68f2986f8cf95be85ca9e7c3fcc/raw/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/350d/c774e68f2986f8cf95be85ca9e7c3fcc/raw/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/350d/c774e68f2986f8cf95be85ca9e7c3fcc/raw/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/350d/c774e68f2986f8cf95be85ca9e7c3fcc/raw/homebridge -O /etc/default/homebridge -q
wget https://gist.githubusercontent.com/350d/c774e68f2986f8cf95be85ca9e7c3fcc/raw/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="7.10.1"
#NODEVERSION="8.16.2"
NODEVERSION="14.13.1"
#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
@350d

This comment has been minimized.

Copy link
Owner Author

@350d 350d commented Nov 11, 2017

  1. Download and install latest RASPBIAN STRETCH LITE on your Pi (use Etcher)
  2. Enable SSH in raspi-config or by creating /boot/ssh.txt file.
  3. Setup your Wifi connection for Raspberry if needed (Zero for example) by creating /boot/wpa_supplicant.conf file with content:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
        ssid="name"
        psk="password"
    }
  1. Run this command from console:
    curl -sL https://goo.gl/Qnx3vP | sudo -E bash -
  2. Use /var/lib/homebridge/config.json to config your Homebridge or HomeBridgeController App
@sassen

This comment has been minimized.

Copy link

@sassen sassen commented Feb 2, 2018

Hi,
I followed the instructions exactly, Pi Zero, Etcher, Stretch Lite etc... but got an error message. Any idea on how solve this?
screenshot 2018-02-02 09 41 55

@350d

This comment has been minimized.

Copy link
Owner Author

@350d 350d commented Feb 7, 2018

@sassen I have Zero W here and everything works fine last time. I will check it with latest script later.

@Sico93

This comment has been minimized.

Copy link

@Sico93 Sico93 commented Feb 17, 2018

@sassen did you manage to get homebridge up and running?
@350d I'm having the exact same issue, running on an Zero W with the latest raspbian-stretch-lite (2017-11-29).

I followed your Instructions above exactly and I am able to reproduce the issue every time.

I Would Really love, if you could help finding a solution 👍

bildschirmfoto 2018-02-18 um 00 22 58

@bperlman

This comment has been minimized.

Copy link

@bperlman bperlman commented Apr 11, 2018

Hi all, I'm having the same issues as @Sico93 and @sassen ... any ideas?

@350d

This comment has been minimized.

Copy link
Owner Author

@350d 350d commented May 4, 2018

@Sico93 @bperlman @sassen Hello! Script was updated with new Homebridge location. You need to run one command from homebridge_full_install line 19 and it will fix your issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment