curl -sL https://deb.nodesource.com/setup_8.x sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y libavahi-compat-libdnssd-dev
sudo npm install -g --unsafe-perm homebridge
sudo useradd --system homebridge
sudo mkdir /etc/homebridge

ip address show eth0 grep link/ether cut -c16-32 tr a-z A-Z    //尋找網卡Mac address


sudo nano /etc/homebridge/config.json
#輸入下列的內容。
{
  "bridge": {
    "name": "Homebridge",
    "username": "XX:XX:XX:XX:XX:XX",    //輸入Mac address
    "port": 54321,
    "pin": "123-45-678"
  }
}
http://jsonlint.com/                //檢查JS語法網站
sudo nano /etc/default/homebridge        //建立 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 /etc/homebridge

# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*

sudo nano /etc/systemd/system/homebridge.service
#輸入下列設定值。
[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
ExecStart=/usr/lib/node_modules/homebridge/bin/homebridge HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

sudo homebridge -U /etc/homebridge -D  //運行Homebridge -Debug

文章標籤
全站熱搜
創作者介紹