Skip to content

Instantly share code, notes, and snippets.

@daniel0076
Created December 5, 2017 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel0076/667d6fb2e0bf0978bba6694b71466ded to your computer and use it in GitHub Desktop.
Save daniel0076/667d6fb2e0bf0978bba6694b71466ded to your computer and use it in GitHub Desktop.
Homebridge init.d script for LEDE/OpenWRT (procd init.d script)
#!/bin/sh /etc/rc.common
# Description: Enable Homebridge on boot
# Author: Daniel Tsai <idaniel.twc@gmail.com>
START=90
USE_PROCD=1
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Print Homebridge run information"
CONF_DIR="/srv/homebridge" # Path to Homebridge config.json
BIN="/usr/bin/homebridge" # Path to Homebridge
USER="homebridge" # Run Homebridge as
is_running() {
pgrep 'homebridge' > /dev/null 2>&1
}
start_service() {
procd_open_instance "homebridge"
procd_set_param command "${BIN}" -U "${CONF_DIR}"
procd_set_param user ${USER} # run service as user homebridge
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
reload_service(){
echo "Restarting Homebridge"
stop
start
}
status()
{
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment