January 20, 2020

Homebridge, autostart made simple

There have been some questions about how to handle Homebridge, (HB), autostart at power on and restart at failure using Raspberry Pi OS systemd

Please note that, in the later versions, the HB installation handles this !!

I have written a post how to manually set it up but now in this post I will present a script which handles it automagically !! 

Despite this simple set up I recommend using the app " hb-service", which is installed together with "homebridge-config-ui-x"

How to install HB is found here !

Log on to your HB installation with ssh/Terminal and issue the command 

wget -q -O - https://raw.githubusercontent.com/MatsA/hb_systemd/master/hb_systemd.sh | sudo bash -

which will do the whole installation job, with user "pi" !!

Something like this will be shown

$ wget -q -O - https://raw.githubusercontent.com/MatsA/hb_systemd/master/hb_systemd.sh | sudo bash -

--------------------------------------------------------------------
This script will install, systemd, autostart and restart at failure 
                       for Homebridge                               

Starting daemon .... please wait

Created symlink /etc/systemd/system/multi-user.target.wants/homebridge.service → /etc/systemd/system/homebridge.service.

Showing status 
--------------------------------------------------------------------

homebridge.service - Node.js HomeKit Server
   Loaded: loaded (/etc/systemd/system/homebridge.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-01-20 20:10:00 CET; 101ms ago
     Docs: https://pysselilivet.blogspot.com/2020/01/homebridge-autostart-made-simple.html
 Main PID: 14127 (node)
    Tasks: 6 (limit: 2200)
   Memory: 1.3M
   CGroup: /system.slice/homebridge.service
           └─14127 node /usr/local/bin/homebridge

Jan 20 20:10:00 Home systemd[1]: Started Node.js HomeKit Server.

If You want to stop HB temporarily and for example run it from the command line just stop the service with 

$ sudo systemctl stop homebridge

and start with 

$ homebridge

after the testing, exit, "Ctrl + c", and start again with 

$ sudo systemctl start homebridge

If You have problems and would like to clean up, use the following commands 

$ sudo systemctl stop homebridge && sudo systemctl disable homebridge

and then delete the file 

/etc/systemd/system/homebridge.service


No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !