Shell command not running script

I am having trouble with getting my shell commands to work correctly. What I am trying to accomplish is have a script that I can run to pull the latest git repo of my configuration. But this isn’t working saying that doesn’t recognize the command.

configuaration.yaml
shell_command: !include shell_command.yaml

shell_command.yaml
git_pull: '/config/scripts/git_pull.sh'

git_pull.sh
#!/bin/bash /usr/bin/git pull origin

error log

2018-11-07 15:50:05 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=shell_command, service=git_pull, service_data=, service_call_id=275ca94278cb44a3b56653efdafef674>
2018-11-07 15:50:05 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of  command: `bash /config/scripts/git_pull.sh`, return code: 127:
b'/config/scripts/git_pull.sh: line 1: /usr/bin/git: No such file or directory\n'
2018-11-07 15:50:05 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `bash /config/scripts/git_pull.sh`, return code: 127 NoneType: None

I’m going to ask a dumb question, please forgive me: Have you tried running the ‘git_pull.sh’ script outside of Home Assistant, but in the context of the user as whom Home Assistant runs?

I am able to run the script successfully as root on Hassio. Would there be another user that I could try this on?

I’m not totally familiar with the way hassio runs, but I run home assistant on a regular Ubuntu machine as a non-root user; that’s why I made that specification about the user.

Not sure about hassio either, maybe try this?
git_pull: ‘sudo /bin/sh /config/scripts/git_pull.sh’

For anyone else looking at this. I want to avoid the git addon for Hassio since i want to try and use automations to pull new configs.

ps aux hass

Should tell you the user hass runs as.

Also where is git on your system?

which git
core-ssh:~# ps aux
PID   USER     TIME  COMMAND
    1 root      0:05 /dev/init -- /run.sh
    8 root      0:00 /usr/sbin/sshd -D -e
  496 root      0:00 sshd: root@pts/0
  498 root      0:00 -bash
  578 root      0:00 ps aux

This is the output of the command

So a few things I have discovered (don’t know if they are relevant though). I ran the script again but with other commands and this is what I got

$ ls
README.md configuartion.yaml customize.yaml ...
$ pwd
/config
$ whoami
root
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Also when I SSH in as root, I am able to run the script and git just fine

1 Like

Hi there, did you get to solve it? I’m facing the same problem and wondering if the hassio system is the reason. Thinking about installing Ubuntu with HA on it but might be just waste of time.