Run Home Assistant on startup on Armbian Debian

I installed Home Assistant Core according to the manual:
https://www.home-assistant.io/installation/linux#install-home-assistant-core

The firrst time it does start and I can access the web interface. After a reboot I cannot access the web interface. I have tried several init.d script to start Home Assistant Core on boot, but so far no succes.

Is there a way to start Home Assitant Core on boot?

It is installed as user “homeassitant”. So I have to start Home Assistant Core with a command and the user that running the command has to be “homeassistant”.

I fixed the issue.

How I fixed the issue:

  1. Create a file named “homeassistant” in “/etc/init.d”.
  2. Copy the code below to the file you just made (check which version of Python you are using).
  3. Make the exacutable: “chmod 0755 /etc/init.d/homeassistant”.
  4. Add the script to run on boot: “update-rc.d homeassistant defaults”.
  5. Reboot your device.
  6. Open in your web browser: http://[Home Assistant IP address]:8123

If you are using Python3.11:

#!/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.11 /srv/homeassistant/bin/hass' &>/dev/null &
		echo $(pgrep python3.11) > "$pid_file"
		echo "Running with PID: $(pgrep python3.11)"
    ;;
    stop)
        echo -n "Stopping $name.."
        kill $(pgrep python3.11)
	rm "/var/run/$name.pid"

    ;;
    restart)
        stop
		start
    ;;
    status)
        if $(pgrep hass); then
            echo "Running with PID: $(pgrep python3.11)"
        else
            echo "$name is not running"
            exit 1
        fi

    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
exit 0

If you are using Python3.12:

#!/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 '/usr/local/bin/python3.12 /srv/homeassistant/bin/hass' &>/dev/null &
		echo $(pgrep python3.12) > "$pid_file"
		echo "Running with PID: $(pgrep python3.11)"
    ;;
    stop)
        echo -n "Stopping $name.."
        kill $(pgrep python3.12)
	rm "/var/run/$name.pid"

    ;;
    restart)
        stop
		start
    ;;
    status)
        if $(pgrep hass); then
            echo "Running with PID: $(pgrep python3.12)"
        else
            echo "$name is not running"
            exit 1
        fi

    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
exit 0