Skip to content

Instantly share code, notes, and snippets.

@350d
Forked from johannrichard/homebridge
Last active October 10, 2020 14:05
Show Gist options
  • Save 350d/c774e68f2986f8cf95be85ca9e7c3fcc to your computer and use it in GitHub Desktop.
Save 350d/c774e68f2986f8cf95be85ca9e7c3fcc 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/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
@bperlman
Copy link

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

@350d
Copy link
Author

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