name="homeassistant"
rcvar=${name}_enable
pidfile=/var/run/${name}.pid
-procname=/home/domotica/ha/bin/hass
-start_precmd="ha_prestart"
+ppidfile=/var/run/${name}-parent.pid
+ha_command=/home/domotica/ha/bin/hass
command=/usr/sbin/daemon
-command_args=" -f -S -p ${pidfile} -u domotica ${procname} --ignore-os-check"
+command_args=" -f -S -p ${pidfile} -P ${ppidfile} -u domotica ${ha_command} --ignore-os-check"
+
+start_precmd="ha_prestart"
+status_cmd="ha_status"
+stop_cmd="ha_stop"
+
ha_prestart()
{
chown -R domotica:domotica /home/domotica/ha
}
+ha_status()
+{
+ if [ -n "`cat $pidfile`" ]; then
+ echo "${name} is running as pid `cat $pidfile`."
+ else
+ echo ${name} is not running.
+ return 1
+ fi
+}
+
+ha_stop()
+{
+ echo "Stopping PID: $(cat ${ppidfile})"
+ /bin/kill -9 $(cat ${ppidfile})
+ rm ${ppidfile}
+ echo "Stopping PID: $(cat ${pidfile})"
+ /bin/kill -15 $(cat ${pidfile})
+ rm ${pidfile}
+}
+
load_rc_config $name
run_rc_command $1