Homekit and Synology Chroot

Ok so it’s a bit of a challenge to get this working for those who don’t have Docker. But here we go.

You need to add the community package source in DSM. In the Package Sources tab, click Add, type SynoCommunity as Name and http://packages.synocommunity.com/ as Location and then press OK to validate. Now the Debian Chroot package is available and you can install it. The community Python package is a requirement and the package manager will ask for permission to install it. After the package is installed, the package will automatically install the necessary files on your filesystem. The status of this installation can be tracked within the package application on the DSM web interface.

ssh into you Synology (ssh admin@NASip)
then enter: sudo -i
then

sed -i s:3rdparty/debian-chroot/debian-chroot.cgi/direct/router:/webman/3rdparty/debian-chroot/debian-chroot.cgi/direct/router: /var/packages/debian-chroot/target/app/debian-chroot.js && sed -i s:3rdparty/debian-chroot/debian-chroot.cgi/direct/poller:/webman/3rdparty/debian-chroot/debian-chroot.cgi/direct/poller: /var/packages/debian-chroot/target/app/debian-chroot.js

/var/packages/debian-chroot/scripts/start-stop-status start /var/packages/debian-chroot/scripts/start-stop-status chroot
then

apt-get update && \ apt-get -y upgrade && \ apt-get -y install locales && \ dpkg-reconfigure locales
then

dpkg-reconfigure tzdata

then

apt-get update && \ apt-get install -y apt-utils nano && \ apt-get install -y \ curl \ wget \ git \ apt-transport-https \ python \ build-essential \ make \ g++ \ libavahi-compat-libdnssd-dev \ libkrb5-dev \ vim \ net-tools \ sudo \ git-core \ libnss-mdns

Then

curl -L https://git.io/n-install | bash -s -- -y

export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"

npm config set registry http://registry.npmjs.org/

npm install -g --unsafe-perm homebridge
npm install -g --unsafe-perm homebridge-vera
rm -r /var/run && rm -r /var/lock && ln -s /run /var/run && ln -s /run/lock /var/lock && rm /run/dbus/*

sed -i s/rlimit-nproc=3/#rlimit-nproc=3/ /etc/avahi/avahi-daemon.conf && sed -i s/AVAHI_DAEMON_DETECT_LOCAL=1/AVAHI_DAEMON_DETECT_LOCAL=0/ /etc/default/avahi-daemon

mkdir /root/.homebridge && printf '%s\n' '#!/bin/bash' '# LANCEMENT DES SERVICES DBUS, AVAHI, HOMEBRIDGE' '# RUNNING DBUS, AVAHI AND HOMEBRIDGE SERVICES' 'export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"' 'dbus-daemon --system' '/etc/init.d/dbus restart' 'service avahi-daemon start' 'homebridge' >/root/.homebridge/run.sh && chmod 755 /root/.homebridge/run.sh

Then modify /root/.homebridge/config.json with your correct info

vi /root/.homebridge/config.json

Then type exit to go back to Synology shell
Then printf '%s\n' '/var/packages/debian-chroot/scripts/start-stop-status start' 'chroot /usr/local/debian-chroot/var/chroottarget/ /root/.homebridge/run.sh' >/volume1/HomeKitVeraAuto.sh chmod 755 /volume1/HomeKitVeraAuto.sh

Then open Task Scheduler in Synology GUI.
Create a schedules task called: HomeKitVera Start
Select user “root”
Choose event: Boot-up
Then in task settings, type: /volume1/HomeKitVeraAuto.sh

Then reboot and see if it shows up on your phone.
Still working out a few kinks.

Thanks! This worked perfectly. It seemed to be the sudo -i command I was missing.

Look at first post

OK. It is running now.

Once this is done should I be able to load homebridge then homebridge-vera next?

If so, I have all the files but not sure how to get them to the right place within the Synology. I guess the only custom part would be my config file.

Look at first post

Ok not working. I’ll have to see what I can do here.

No Problem. Hours later STILL loading from the following lines:

git clone GitHub - nodejs/node-v0.x-archive: Moved to https://github.com/nodejs/node
cd node
git checkout v0.12.4
./configure --openssl-libpath=/usr/lib/ssl
make
make install

Yes, once the install finished it seemed to error out on the last couple steps. I tried to run the NPM lines but it didn’t work. ???

Seems to be the “make” command where the errors start to occur. I listed below what happened when it go to that line:

root@Synology-White:/node# make
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory ‘/node/out’
LD_LIBRARY_PATH=/node/out/Release/lib.host:/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd …/deps/v8/tools/gyp; mkdir -p /node/out/Release/obj.target/v8_snapshot/geni; “/node/out/Release/mksnapshot” --log-snapshot-positions --logfile “/node/out/Release/obj.target/v8_snapshot/geni/snapshot.log” “/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc”
Illegal instruction
deps/v8/tools/gyp/v8_snapshot.target.mk:13: recipe for target ‘/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc’ failed
make[1]: *** [/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc] Error 132
make[1]: Leaving directory ‘/node/out’
Makefile:45: recipe for target ‘node’ failed
make: *** [node] Error 2

Not sure if that helps?

So, not sure how I got here but I actually got Homebridge and Homebridge-Vera to load. When I tried typing in the Homebridge command I got the scan code…and then it popped up an Error. Here is what that part looks like:

root@Synology-White:/# homebridge
*** WARNING *** The program ‘(unknown)’ uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=(unknown)
*** WARNING *** The program ‘(unknown)’ called ‘DNSServiceRegister()’ which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=(unknown)&f=DNSServiceRegister
[Tue Oct 18 2016 15:27:58 GMT-0400 (EDT)] Loaded plugin: homebridge-vera
VeraLink initializing
[Tue Oct 18 2016 15:27:59 GMT-0400 (EDT)] Registering platform ‘homebridge-veralink.Vera’
[Tue Oct 18 2016 15:27:59 GMT-0400 (EDT)] —
[Tue Oct 18 2016 15:27:59 GMT-0400 (EDT)] config.json (/root/.homebridge/config.json) not found.
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     

/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/lib/advertisement.js:56
dns_sd.DNSServiceRegister(self.serviceRef, flags, ifaceIdx, name,
^

Error: dns service error: unknown
at Error (native)
at new Advertisement (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/lib/advertisement.js:56:10)
at Object.create [as createAdvertisement] (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/lib/advertisement.js:64:10)
at Advertiser.startAdvertising (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Advertiser.js:43:30)
at Bridge.Accessory._onListening (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:526:20)
at emitOne (events.js:77:13)
at HAPServer.emit (events.js:169:7)
at HAPServer._onListening (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:184:8)
at emitOne (events.js:77:13)
at EventedHTTPServer.emit (events.js:169:7)
at EventedHTTPServer. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/eventedhttp.js:64:10)
at emitNone (events.js:67:13)
at Server.emit (events.js:166:7)
at emitListeningNT (net.js:1260:10)
at doNTCallback1 (node.js:428:9)
at process._tickCallback (node.js:350:17)
at Function.Module.runMain (module.js:469:11)
at startup (node.js:134:18)
at node.js:961:3

I believe part of the problem now is that the config.json file is missing or empty. I have the correct file I am just not sure how to get that file to the location it needs to be.

Thanks again for all your help so far!

OK…as you can see below I was able to get homebridge working… :slight_smile:


[Tue Oct 18 2016 21:46:42 GMT-0400 (EDT)] Loaded plugin: homebridge-vera
VeraLink initializing
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] Registering platform ‘homebridge-veralink.Vera’
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] —
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] Loaded config.json with 0 accessories and 1 platforms.
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] —
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] Loading 1 platforms…
[Tue Oct 18 2016 21:46:43 GMT-0400 (EDT)] [Vera] Initializing Vera platform…
we have a switch
Process Device 45: Dim Light Switch
Process Device 4: Energy SmartSwitch
Process Device 46: GDC1_GarageDoor
Process Device 49: Kitchen_Table_Light
Process Device 5: LampHolder
Process Device 50: Master_Bed_Hallway
Process Device 48: Wall Plug
Process Device 3: Alarm - Away
Process Device 4: Alarm - Home
Process Device 5: Alarm - Night
Process Device 6: Alarm - Vacation
Process Device 9: AlarmTriggerAway
Process Device 8: AlarmTriggerHome
Process Device 10: AlarmTriggerNight
Process Device 11: AlarmTriggerVacation
Process Device 14: AtticDoorTrigger
Process Device 19: Back Door Record Trigger
Process Device 43: Birthday_Lights(off)1
Process Device 45: Birthday_Lights(off)2
Process Device 42: Birthday_Lights(on)1
Process Device 44: Birthday_Lights(on)2
Process Device 20: Garage Entry Record Trigger
Process Device 32: GarageDoor-CLOSE
Process Device 31: GarageDoor-OPEN
Process Device 41: GarageNotClosed-Notification (A)
Process Device 39: GarageNotClosed-Notification (V)
Process Device 30: MasterBedHall_Switch-off
Process Device 29: MasterBedHall_Switch-on
Process Device 18: Motion Sensor Record
Process Device 16: Motion_Nightlight
Process Device 17: Night Dim Light (off)
Process Device 15: Night Dim Light (on)
Process Device 23: Preset_1 Camera
Process Device 24: Preset_2 Camera
Process Device 25: Preset_3 Camera
Process Device 46: Vacation Light ON/OFF
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Dim Light Switch’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Energy SmartSwitch’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘GDC1_GarageDoor’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Kitchen_Table_Light’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘LampHolder’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Master_Bed_Hallway’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Wall Plug’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Alarm - Away’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Alarm - Home’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Alarm - Night’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Alarm - Vacation’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘AlarmTriggerAway’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘AlarmTriggerHome’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘AlarmTriggerNight’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘AlarmTriggerVacation’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘AtticDoorTrigger’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Back Door Record Trigger’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Birthday_Lights(off)1’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Birthday_Lights(off)2’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Birthday_Lights(on)1’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Birthday_Lights(on)2’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Garage Entry Record Trigger’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘GarageDoor-CLOSE’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘GarageDoor-OPEN’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘GarageNotClosed-Notification (A)’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘GarageNotClosed-Notification (V)’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘MasterBedHall_Switch-off’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘MasterBedHall_Switch-on’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Motion Sensor Record’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Motion_Nightlight’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Night Dim Light (off)’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Night Dim Light (on)’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Preset_1 Camera’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Preset_2 Camera’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Preset_3 Camera’…
[Tue Oct 18 2016 21:46:44 GMT-0400 (EDT)] [Vera] Initializing platform accessory ‘Vacation Light ON/OFF’…
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ 031-45-154 │     
└────────────┘     

However, I seem to now be stuck at what seems to be the easiest part…How do I get this working directly from the Synology so it will run automatically whenever the Synology NAS is on?

On DSM6 the easiest way is to create a script in /volume1/
Then you use task scheduler in the GUI to start it at boot up

Thanks! I will try to do some research and figure that out.

Is it a problem that Homebridge only seems to work from the “root” login?

Sent from my iPhone using Tapatalk

OK…I think I am official stuck here ???

I can see that HOMEBRIDGE is running! However, it seems that no matter what I have tried I can’t get my iPhone to recognize HOMEBRIDGE. I didn’t have this issue with any of the computers I loaded home bridge on previously, just this load. So, there is obviously something additional to logging in my my computer, SSH into my Synology, and run HOMEBRIDGE.

I also made sure Debian Chroot was running and everything was on the same network.

Any ideas on what I am missing? There must be something I need to load/run directly on the Synology without SSH in from another computer because I don’t see why if I can see it running in my Terminal window it will not connect. ???

Hey I’m prettt busy this week but I’ll probably get to this on the weekend. Still trying to get node.sj/npm to work properly. Think I’ll have to download the architecture specific deb package for the right version of node to make it all work

No Problem! Thanks for all the suggestions so far. Gives me something new to try and learn in the evenings ;D

Just a couple quick updates I found:

  1. Apparently there is a bug in the DSM 6.0 Chroot GUI which could be part of the reason this is not all working. If you look at this link below, there is a fix but I can’t figure out a way to get into the script location to EDIT the file because the NANO command is not working.

For fix SynoCommunity’s Debian-Chroot Web GUI on DSM6:
We have to edit file:
/var/packages/debian-chroot/target/app/debian-chroot.js
and change lines, from:
“url”: “3rdparty/debian-chroot/debian-chroot.cgi/direct/router”,
to:
“url”: “/webman/3rdparty/debian-chroot/debian-chroot.cgi/direct/router”,
and:
‘url’: ‘3rdparty/debian-chroot/debian-chroot.cgi/direct/poller’,
to:
‘url’: ‘/webman/3rdparty/debian-chroot/debian-chroot.cgi/direct/poller’,
After that, web interface is working again :wink:

  1. I also realized that the SSH was not set-up 100% correctly for inside of Chroot. I was trying to follow the directions on this website

to fix the install. It all seems to work until I get to the section of running this line

nano /var/packages/debian-chroot/scripts/start-stop-status

outside of chroot environment. For some reason the NANO command only works inside the chroot environment. I tried to load NANO per other websites I found but the apt-get file is not working either :slight_smile:

Instead of nano, use vi
Here’s the commands http://www.lagmonster.org/docs/vi.html

Thanks FastFreddi ! The “vi” option worked perfectly as a replacement for nano. Pretty easy to edit with once I played around with it a bit.

So, EVERYTHING seems to be working and I can see Homebridge running in the Terminal window. However, I STILL can’t get it to connect with my iPhone “Home” app. I can run the same Homebridge installs from my computer(s) and it connects just fine.

I believe the issue is that Chroot is not running the “service”. As you can see from the attached picture I was able to fix the Chroot install so the Services work. The SSH service is running directly in Chroot. I think the only thing missing now is that I don’t understand how to add Homebridge as a “service” in Chroot.

Is there an easy way to wipe everything out in Chroot and start over again? I hate to do it but I feel as if I have tried everything and duplicate installs of certain items might be the issue. For example: When I run home bridge from my Mac Terminal window as root it runs fine. However, when I run as the admin it gives an error. I can tell it is looking at the wrong config.json file because I changed the key on the root version and the admin version has the old information. Not sure why this happened because I installed Homebridge and Homebridge-Vera globally.

Hopefully there is a way to test running as a Chroot Service but I can’t seem to find anything out there which explains what the “launch scripts” and “status command” might be to start this service in Chroot (only found one showing the settings for setting up internal Chroot SSH, which I did get to work).