Start Home Assistant CLI on tty1 without login (#1366)

* Start ha-cli on tty1 instead of a getty

Instead of starting a getty start the ha-cli directly. This will show
the banner right on startup with the important information such as IP
address of the instance or the URL to reach it.

* Use default shell as root shell instead of HA CLI

Instead of using the ha-cli.sh script as login shell use the regular
shell. Amongst other things, this allows to run VS Code devcontainers
remotely via SSH or using scp. The HA CLI is still available using the
`ha` command.
This commit is contained in:
Stefan Agner
2021-05-19 13:18:02 +02:00
committed by GitHub
parent 25d1f5d7d1
commit 40b4d5ca2e
20 changed files with 59 additions and 57 deletions

View File

@@ -3,35 +3,23 @@
# Run logging cli
# ==============================================================================
# Setup terminal size on serial console
if [ "${TERM}" = "vt220" ] || [ "${TERM}" = "vt102" ] || \
[ "${TERM}" = "vt100" ]; then
resize
fi
echo "Waiting for the Home Assistant CLI to be ready..."
if [ "$(systemctl is-active default.target)" != "active" ]; then
echo "[INFO] System not in default.target! Jump into emergency console..."
exec /bin/ash -l
fi
if [ ! "$(findmnt /mnt/data)" ]; then
echo "[WARN] Data partition not mounted! Jump into emergency console..."
exec /bin/ash -l
fi
# Run CLI container
if [ "$(docker ps -q -f name=hassio_cli)" ]; then
docker container exec \
-ti hassio_cli \
/usr/bin/cli.sh \
# Jump to root login shell
if [ $? -eq 10 ]; then
/bin/ash -l
i=0
while [ ! "$(docker ps -q -f name=hassio_cli)" ]; do
sleep 1
i=$((i+1))
if [ $i = 60 ]; then
echo "[WARN] Home Assistant CLI not starting! Jump into emergency console..."
exec /bin/ash -l
fi
else
echo "[WARN] Home Assistant CLI is not running! Jump into emergency console..."
done
docker container exec \
-ti hassio_cli \
/usr/bin/cli.sh
# Jump to root login shell
if [ $? -eq 10 ]; then
exec /bin/ash -l
fi
exit