#!/bin/sh # For Ubuntu: # description: Home Assistant # processname: hass ### BEGIN INIT INFO # Provides: hass # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Home Assistant service # Description: Home Assistant ### END INIT INFO name="HomeAssistant" pid_file="/var/run/$name.pid" case "$1" in start) su - homeassistant -c '/srv/homeassistant/bin/python3.13 /srv/homeassistant/bin/hass' &>/dev/null & echo $(pgrep python3.13) > "$pid_file" echo "Running with PID: $(pgrep python3.13)" ;; stop) echo -n "Stopping $name.." kill $(pgrep python3.13) rm "/var/run/$name.pid" ;; restart) stop start ;; status) if $(pgrep hass); then echo "Running with PID: $(pgrep python3.13)" else echo "$name is not running" exit 1 fi ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0