Skip to content

Instantly share code, notes, and snippets.

@micw
Last active May 8, 2017 20:23
Show Gist options
  • Select an option

  • Save micw/2194865e463e6ed77ddd4150b386cb02 to your computer and use it in GitHub Desktop.

Select an option

Save micw/2194865e463e6ed77ddd4150b386cb02 to your computer and use it in GitHub Desktop.
Homeassitant rc script
#!/sbin/openrc-run
CONFIG_DIR=/etc/homeassistant
USER=hass
GROUP=daemon
PIDFILE=/var/run/homeassistant/homeassistant.pid
CMD="/usr/bin/hass"
ARGS="-c ${CONFIG_DIR} --pid-file ${PIDFILE}"
depend() {
use dns
}
start() {
mkdir -p /var/log/homeassistant
chown -R ${USER}.${GROUP} /var/log/homeassistant
mkdir -p /var/run/homeassistant
chown -R ${USER}.${GROUP} /var/run/homeassistant
ebegin "Starting ${SVCNAME}"
start-stop-daemon --pidfile $PIDFILE -u $USER -g $GROUP -b \
-1 /var/log/homeassistant/homeassistant.log \
-2 /var/log/homeassistant/homeassistant.log \
-x $CMD -- $ARGS
eend $?
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --pidfile $PIDFILE -u $USER -g $GROUP -x $CMD -K -q
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment