Homebridge Jail

Status
Not open for further replies.

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14
Hello All -

I've been racking my brain trying to figure out how to install Homebridge (https://github.com/nfarina/homebridge) in a jail.

This is what I've done so far:

1. Created a new jail
2. pkg update & pkg upgrade
3. pkg install node
4. pkg install npm
5. npm install -g homebridge

Now this is where I get issues. I've got the output located here: https://gist.github.com/anonymous/90ef77f6bc5275cb3ad1

And my npm-debug.log can be found here: https://gist.github.com/anonymous/e76842241e4a208ce48d

It seems like it failing has something to do with node-gyp but I'm not too familiar with node.

Has anyone else tried to get Homebridge installed??
 

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14
Did you get any farther with this?

Not really. I ended up creating an Ubuntu VM in VirtualBox and got it working that way. Haven't had time to try and go back and get it working right on a jail.
 

Axemann

Dabbler
Joined
Jun 6, 2015
Messages
21
I think the issue may be the version of GCC that's installed as part of the jail package (4.2.1), in that it doesn't support the compiler flags being passed to it (-std=gnu++0x) by the node packages when they're being built. I'm not a developer by any stretch, so this could be totally wrong.
 

Axemann

Dabbler
Joined
Jun 6, 2015
Messages
21
I think I may have figured out how to get this to work (via some Google-fu and trial-and-error)... I'm still putting the finishing touches on the install process, but hopefully I can have something workable I can post tomorrow at the latest.
 

Axemann

Dabbler
Joined
Jun 6, 2015
Messages
21
EDIT: I made a few changes to incorporate using PM2 to start and control the Homebridge installation, since I was pulling my hair out trying to daemon-ize it manually. Steps 6 and 9 install PM2 and set it to run at startup.

OK, gents, I believe I have worked out how to get Homebridge installed in a jail in FreeNAS. It took a bit of Googling and poking around in things, but you should be able to create a standard jail and paste in the following to get Homebridge installed (I recommend enabling sshd and using putty or another SSH client):
Code:
pkg install -y node npm dbus avahi-libdns
sysrc dbus_enable="YES"
sysrc avahi_daemon_enable="YES"
ln -s /usr/local/include/avahi-compat-libdns_sd/dns_sd.h /usr/include/dns_sd.h
env CC=/usr/local/bin/gcc48 CXX=/usr/local/bin/g++48 npm install -g homebridge
npm install -g pm2
service dbus start
service avahi-daemon start
pm2 startup
sysrc pm2_enable="YES"
mkdir ~/.homebridge
cp /usr/local/lib/node_modules/homebridge/config-sample.json ~/.homebridge/config.json


You'll have to edit the ~/.homebridge/config.json to work with your particular configuration, but that should be documented fairly well on the project's Github page. I also haven't worked out a startup script to run this as a service (yet), so if anyone that tests this is a whiz at cranking those out, feel free to give it a whirl.

Once you have your config.json file built and working, run:
Code:
pm2 start homebridge -- -D
to start Homebridge and let it run as a daemon. PM2 will automatically start the process at boot-time, so no need for any further hackery in that department. :)

Just an FYI: This was tested while running as root, which is probably a Very Bad Thing, but I believe it should work properly under another user. Also, VIMAGE was enabled on the jail, since I was unable to get the Bonjour/avahi service advertisement to work properly without it during my testing.

Best of luck, and let me know how it goes!
 
Last edited:

zerocool2007a

Dabbler
Joined
Oct 22, 2015
Messages
14
@Axemann I think I owe you a six pack! Worked perfectly the first time I tried it out. I don't have anything to test it with yet but it appears to be running perfectly. Thank you!!!
 

Gonzalo

Patron
Joined
Nov 29, 2014
Messages
457
Aditional step for FreeNAS 9.10:

If you try to install it on FreeNAS 9.10, you'll get an error because gcc is no longer in FreeBSD base since version 10.0.
So, you need to run pkg install gcc before run env CC=/usr/local/bin/gcc48 CXX=/usr/local/bin/g++48 npm install -g homebridge.

Thanks for the steps @Axemann!
 

fracai

Guru
Joined
Aug 22, 2012
Messages
1,212
I also haven't had any luck with PM2 starting HomeBridge when the jail restarts. Maybe I missed a step. Alternatively, I'm going to investigate just creating an RC script.
 

Gonzalo

Patron
Joined
Nov 29, 2014
Messages
457
I also haven't had any luck with PM2 starting HomeBridge when the jail restarts. Maybe I missed a step. Alternatively, I'm going to investigate just creating an RC script.
Having the same issue, I found the solution:
  • Edit the file /etc/rc.d/pm2 and change the line pidfile="/home/${pm2_user}/.pm2/${name}.pid" for pidfile="/${pm2_user}/.pm2/${name}.pid" (without home).
  • After the execution of pm2 start homebridge -- -D, execute pm2 save to create the file ~/.pm2/dump.pm2.
  • Restart the service with /etc/rc.d/pm2 restart (or restart the jail).
  • Execute pm2 list to see homebridge running again ;).
 
Last edited:

cswelin

Cadet
Joined
Jan 27, 2014
Messages
1
I've followed all the steps above by Axeman, however i'm running into issues with bignum dependency

Code:
ode-pre-gyp ERR! Tried to download: https://rvagg-node.s3-us-west-2.amazonaws.com/bignum/v0.12.5/bignum-v0.12.5-node-v48-freebsd-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bignum@0.12.5 and node@6.2.1 (node-v48 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/homebridge/node_modules/bignum/.node-gyp"
gmake: Entering directory '/usr/local/lib/node_modules/homebridge/node_modules/bignum/build'
gmake: *** No rule to make target '../.node-gyp/6.2.1/include/node/common.gypi', needed by 'Makefile'.  Stop.
gmake: Leaving directory '/usr/local/lib/node_modules/homebridge/node_modules/bignum/build'
gyp ERR! build error
gyp ERR! stack Error: `gmake` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System FreeBSD 10.3-STABLE
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node" "--module_name=bignum" "--module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/bignum
gyp ERR! node -v v6.2.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:852:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
node-pre-gyp ERR! System FreeBSD 10.3-STABLE
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/homebridge/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/bignum
node-pre-gyp ERR! node -v v6.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding' (1)
/usr/local/lib
`-- (empty)

npm ERR! FreeBSD 10.3-STABLE
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "homebridge"
npm ERR! node v6.2.1
npm ERR! npm  v3.10.2
npm ERR! code ELIFECYCLE

npm ERR! bignum@0.12.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bignum@0.12.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bignum package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bignum
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bignum
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
npm ERR! code 1


Any ideas on how to solve this?
 

Kuro Houou

Contributor
Joined
Jun 17, 2014
Messages
193
I've followed all the steps above by Axeman, however i'm running into issues with bignum dependency

Code:
ode-pre-gyp ERR! Tried to download: https://rvagg-node.s3-us-west-2.amazonaws.com/bignum/v0.12.5/bignum-v0.12.5-node-v48-freebsd-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bignum@0.12.5 and node@6.2.1 (node-v48 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/homebridge/node_modules/bignum/.node-gyp"
gmake: Entering directory '/usr/local/lib/node_modules/homebridge/node_modules/bignum/build'
gmake: *** No rule to make target '../.node-gyp/6.2.1/include/node/common.gypi', needed by 'Makefile'.  Stop.
gmake: Leaving directory '/usr/local/lib/node_modules/homebridge/node_modules/bignum/build'
gyp ERR! build error
gyp ERR! stack Error: `gmake` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System FreeBSD 10.3-STABLE
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node" "--module_name=bignum" "--module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/bignum
gyp ERR! node -v v6.2.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:852:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
node-pre-gyp ERR! System FreeBSD 10.3-STABLE
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/homebridge/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/bignum
node-pre-gyp ERR! node -v v6.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.28
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding/bignum.node --module_name=bignum --module_path=/usr/local/lib/node_modules/homebridge/node_modules/bignum/binding' (1)
/usr/local/lib
`-- (empty)

npm ERR! FreeBSD 10.3-STABLE
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "homebridge"
npm ERR! node v6.2.1
npm ERR! npm  v3.10.2
npm ERR! code ELIFECYCLE

npm ERR! bignum@0.12.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bignum@0.12.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bignum package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bignum
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bignum
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
npm ERR! code 1


Any ideas on how to solve this?


I have the same errors, running FreeNas 9.10.. did you find a fix?
 

Axemann

Dabbler
Joined
Jun 6, 2015
Messages
21
Guys,

It looks like something changed upstream with the homebridge node dependencies (mainly bignum), so I'll work on editing my commands above to get this functional again.
 

Axemann

Dabbler
Joined
Jun 6, 2015
Messages
21
Guys,

Sorry it took me so long to return to this. Work has been murder. :eek:

Here are the updated steps to install this in a FreeNAS 9.10 jail (and presumably generic FreeBSD 10.3):

Code:
pkg install -y node npm dbus avahi-libdns gcc
sysrc dbus_enable="YES"
sysrc avahi_daemon_enable="YES"
ln -s /usr/local/include/avahi-compat-libdns_sd/dns_sd.h /usr/include/dns_sd.h
npm install bignum
npm install -g homebridge
npm install -g homebridge-smartthings
npm install -g pm2
service dbus start
service avahi-daemon start
pm2 startup
sysrc pm2_enable="YES"
mkdir ~/.homebridge
cp /usr/local/lib/node_modules/homebridge/config-sample.json ~/.homebridge/config.json

pm2 start homebridge -- -D
pm2 save


Remember to edit ~/.homebridge/config.json to customize it for your setup prior to starting Homebridge for the first time.

I've tested this in several fresh 9.10 jails, and the service starts, runs, and starts automatically after a reboot/restart of the jail. Unfortunately, the same can't be said for Homebridge itself, which seems to disappear from Homekit for no reason after a time, while still happily running in the jail. :mad:

Thanks to @Gonzalo for pointing out the 'pm2 save' step earlier in the thread (now that I think on it, I'm pretty sure I had to run that in 9.3 too and totally forgot about it. Doh!). That was driving me nuts for a while when testing this earlier and I happened to remember to check this thread. :D

Anyhoo, let me know how it goes!
 

RedTJ

Cadet
Joined
Nov 20, 2016
Messages
2
Hey Guys - Reviving this older thread.
So I followed this guide but instead of installing homebridge-smarthings, I installed the home bridge-wink plugin.

I wanted to see if any of you ran into this issue..
Code:
[11/20/2016, 4:58:21 PM] No plugins found. See the README for information on ins
talling plugins.																
[11/20/2016, 4:58:21 PM] Loaded config.json with 0 accessories and 1 platforms.
[11/20/2016, 4:58:21 PM] ---													
[11/20/2016, 4:58:21 PM] Loading 1 platforms...								 
/usr/local/lib/node_modules/homebridge/lib/api.js:118						   
	  throw new Error("The requested platform '" + name + "' was not registered
by any plugin.");															   
	  ^																		 
																				
Error: The requested platform 'wink' was not registered by any plugin.		 
	at API.platform (/usr/local/lib/node_modules/homebridge/lib/api.js:118:13) 
	at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.
js:281:45)																	 
	at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:77:36) 
	at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
	at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge
:17:22)																		 
	at Module._compile (module.js:570:32)									   
	at Object.Module._extensions..js (module.js:579:10)						 
	at Module.load (module.js:487:32)										   
	at tryModuleLoad (module.js:446:12)										 
	at Function.Module._load (module.js:438:3)


My config file looks like this..
Code:
{
	"bridge": {
		"name": "Homebridge",
		"username": "CC:22:3D:E3:CE:30",
		"port": 51826,
		"pin": "031-45-154"
	},
   
	"platforms": [
		{
			"platform": "Wink",
			"name": "Wink",
			"client_id": "-NgOLPBVWpW1ZCIp6S4WP4Rl7lvsxFbz / ",
			"client_secret": "w_6m2XCVotgnn1AdlA1xBXg27zDWdFHS",
			"username": "XXXXXXX@icloud.com",
			"password": "XXXXXXXXXX"
		}
	]
}



When I run
NPM INSTALL -G HOMEBRIDGE-WINK
I get the following.

Code:
root@HKJail:/ # npm install -g homebridge-wink								 
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue													 
npm WARN deprecated graceful-fs@2.0.3: graceful-fs v3.0.0 and before will fail o
n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible
. Use 'npm ls graceful-fs' to find it in the tree.							 
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue													
/usr/local/lib																 
└── homebridge-wink@1.2.0	 


Any help would be appreciated. Thanks!!
 
Status
Not open for further replies.
Top