Created
December 5, 2017 14:27
-
-
Save daniel0076/667d6fb2e0bf0978bba6694b71466ded to your computer and use it in GitHub Desktop.
Homebridge init.d script for LEDE/OpenWRT (procd init.d script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh /etc/rc.common | |
# Description: Enable Homebridge on boot | |
# Author: Daniel Tsai <[email protected]> | |
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