Files
operating-system/buildroot-external/rootfs-overlay/usr/sbin/hassos-cli
Stefan Agner 905aa21e8c Only start the HA CLI if we are in the default.target (#1287)
This makes sure that we always get a Linux shell in other targets such
as the rescue.target.
2021-03-24 19:14:06 +01:00

38 lines
998 B
Bash
Executable File

#!/bin/sh
# ==============================================================================
# Run logging cli
# ==============================================================================
# Setup terminal size on serial console
if [ "${TERM}" = "vt220" ] || [ "${TERM}" = "vt102" ] || \
[ "${TERM}" = "vt100" ]; then
resize
fi
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
fi
else
echo "[WARN] Home Assistant CLI is not running! Jump into emergency console..."
exec /bin/ash -l
fi
exit