-
Notifications
You must be signed in to change notification settings - Fork 20
Usage
If you're using systemd
to launch homebridge, the config.json
should look like:
{
"platform": "Server",
"port" : 8765,
"name" : "Homebridge Server",
"log" : "systemd",
"restart" : "sudo systemctl restart homebridge"
}
Execute the following code to allow the service-user to read the journalctl
-logs:
sudo usermod -a -G systemd-journal homebridge
whereas systemd-journal
is the journalctl-group and homebridge
is the user executing the homebridge-service (you've specified him in the service-file).
Restart the homebridge-service and you should see the log-file on the webpage.
See how-to-automatically-start-homebridge-with-launchd for the basic setup.
Make sure, that you choose a writeable path for your log-file and adapt the path in the *.plist
-file accordingly!
Create a script, e.g ~/.homebridge/restart.sh
with the following contents:
#!/bin/sh
launchctl unload ~/Library/LaunchAgents/com.homebridge.server.plist && launchctl load ~/Library/LaunchAgents/com.homebridge.server.plist
Make it executable with:
sudo chmod a+x ~/.homebridge/restart.sh
Then set the restart command to ~/.homebridge/restart.sh &
If you've successfully setup launchd
to launch homebridge, the config.json
should look like:
{
"platform": "Server",
"port" : 8765,
"name" : "Homebridge Server",
"log" : "<THE_PATH_YOUVE_SPECIFIED_IN_THE_PLIST>",
"restart" : "~/.homebridge/restart.sh"
}
If you're calling homebridge with a script or execute it on the command-line, you should pipe its output to a file.
The config.json
should look like:
{
"platform": "Server",
"port" : 8765,
"name" : "Homebridge Server",
"log" : "/var/log/homebridge.log",
"restart" : "sudo reboot"
}
and the command to launch homebridge should look like:
homebridge > /var/log/homebridge.log 2>&1 &
Due to all the different systems around the world, I gave the user the ability to decide what my plugin should do when you hit the Reboot button. The reboot makes the changes in the config permanent.
You can specify what my plugin should do in your config.json
.
Make sure that the user executing homebridge is allowed to execute this command.
Some examples are:
sudo reboot
sudo systemctl restart homebridge
echo "Hello World"
- etc.
To enable a normal user (hans
in this case) to execute these commands, make sure you've added him as follows to the /etc/sudoers
-file:
hans ALL = NOPASSWD: /bin/reboot,/usr/bin/systemctl
To install and remove plugins you need to make sure, that the user executing your homebridge is allowed to execute the npm install
and npm uninstall
-commands.
To enable a user (hans
in this case) to execute these commands, make sure you've added him as follows to the /etc/sudoers
-file:
hans ALL = NOPASSWD: /usr/local/bin/npm
home | Installation | Configuration | Usage