Skip to content

Commit

Permalink
Only run HA CLI interactively if stdout is a terminal
Browse files Browse the repository at this point in the history
Flags for running HA CLI commands in an interactive shell added in #3238
cause the command to fail if the process is not running in a terminal.
This is needed for example for the fsfreeze hook, otherwise the command
fails, as seen in this trace when the hook is executed:

-----------
+ '[' thaw '=' freeze ]
+ '[' thaw '=' thaw ]
+ echo 'File system thaw requested, thawing Home Assistant'
File system thaw requested, thawing Home Assistant
+ ha backups thaw
the input device is not a TTY
------------

However, for example on Proxmox this message is not logged anywhere and
the hook just fails silently (i.e. it doesn't cause the backup to fail).

Fixes #3251
  • Loading branch information
sairon committed Apr 8, 2024
1 parent 974812a commit 3da2e2e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion buildroot-external/rootfs-overlay/usr/bin/ha
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
# HA utility
# ==============================================================================

docker exec -it hassio_cli ha "$@"
if [ -t 1 ]; then
# stdout (fd 1) must be terminal, otherwise `docker exec -ti` fails
docker exec -it hassio_cli ha "$@"
else
docker exec hassio_cli ha "$@"
fi

0 comments on commit 3da2e2e

Please sign in to comment.