Running commands on the host without ssh

Great, thanks for sharing this @navels !!

I only tweaked your script a bit in my env in order to get it generic and allow any script to be launched without being required to update and relaunch the monitoring pipe script for each new script you’d need and also getting default logging. I just expect any command send to the pipe is matching with a script existing in the HA folder. :

#!/bin/bash
ha_home=/home/user/homeassistant
pipe=$ha_home/pipes/host_executor_queue

while true; do
  if read line < $pipe; then
        $ha_home/$line.sh >> $ha_home/$line.log 2>&1
  fi
done

so

shell_command:
  create_zip: 'echo create_zip > /config/pipes/host_executor_queue'

will trigger the create_zip.sh script within home assistant home folder

btw, the nohup was not immediately recognized on my ubuntu host, just running it with ./$HOME/bin/monitor_ha_queue.sh >&/dev/null & and added @reboot $HOME/bin/monitor_ha_queue.sh into crontab -e

2 Likes