#!/bin/bash

sed -i "s/rlimit-nproc=3/#rlimit-nproc=3/" /etc/avahi/avahi-daemon.conf

cd /root/.homebridge
file="/root/.homebridge/package.json"
if [ -f "$file" ]
then
	echo "$file found. Going to install additional plugins."
	npm run install
else
	echo "$file not found. You can create this file to install additional plugins not already included in the docker image."
fi

dbus-daemon --system
avahi-daemon -D

homebridge

#!/bin/bash

sed -i "s/rlimit-nproc=3/#rlimit-nproc=3/" /etc/avahi/avahi-daemon.conf

cd /root/.homebridge
file="/root/.homebridge/package.json"
if [ -f "$file" ]
then
	echo "$file found. Going to install additional plugins."
	npm run install
else
	echo "$file not found. You can create this file to install additional plugins not already included in the docker image."
fi

rm /var/run/dbus/pid

dbus-daemon --system
avahi-daemon -D

homebridge

Remove the dbus pid file on startup to resolve unclean shutdown failures
Remove the dbus pid file on startup to resolve unclean shutdown failures

When the container is restarted it fails to start dbus properly due
to stale files;

Failed to start message bus: The pid file "/var/run/dbus/pid" exists, if the message bus is not running, remove this file
Process 10 died: No such process; trying to remove PID file. (/var/run/avahi-daemon//pid)
