Skip to content

Instantly share code, notes, and snippets.

@sicaboy
Forked from johannrichard/homebridge
Created December 22, 2017 11:35
Show Gist options
  • Save sicaboy/66af141d8449a8f016bef19a42c3ecf0 to your computer and use it in GitHub Desktop.
Save sicaboy/66af141d8449a8f016bef19a42c3ecf0 to your computer and use it in GitHub Desktop.
Systemd Service for homebridge (http://github.com/nfarina/homebridge)
# 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/local/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
@sicaboy
Copy link
Author

sicaboy commented Dec 22, 2017

Those who have the problem:

homebridge.service: Failed at step EXEC spawning /usr/local/bin/homebridge: No such file or directory

Simply fix by running:

ln -s   /opt/nodejs/bin/homebridge   /usr/local/bin/homebridge

@sicaboy
Copy link
Author

sicaboy commented Dec 22, 2017

The script for setting up a brand new Homebridge Raspberry pi from scratch:

sudo wget -O - https://raw.githubusercontent.com/audstanley/NodeJs-Raspberry-Pi/master/Install-Node.sh | sudo  bash

sudo apt-get install libavahi-compat-libdnssd-dev  vim

sudo su

npm install -g homebridge
npm install -g homebridge-openweathermap-temperature


wget -O /etc/default/homebridge    https://gist.githubusercontent.com/sicaboy/66af141d8449a8f016bef19a42c3ecf0/raw/1cf926e63e553c7cbfacf9970042c5ac876fadfa/homebridge

wget -O /etc/systemd/system/homebridge.service    https://gist.githubusercontent.com/sicaboy/66af141d8449a8f016bef19a42c3ecf0/raw/1cf926e63e553c7cbfacf9970042c5ac876fadfa/homebridge.service


useradd -M --system homebridge
mkdir /var/lib/homebridge
chmod -R 777 /var/lib/homebridge
vim  /var/lib/homebridge/config.json

ln -s   /opt/nodejs/bin/homebridge   /usr/local/bin/homebridge

systemctl daemon-reload
systemctl enable homebridge
systemctl start homebridge

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