Shell Command

shell_commands.yaml

#Front Cam
  front_preset_1: '/home/hass/shell_scripts/f_preset1.sh'
  front_preset_2: '/home/hass/shell_scripts/f_preset2.sh'
  front_preset_3: '/home/hass/shell_scripts/f_preset3.sh'
  ir_off: '/home/hass/shell_scripts/ir_off.sh'

#Rear Cam
  rear_preset_1: '/home/hass/shell_scripts/r_preset1.sh'
  rear_preset_2: '/home/hass/shell_scripts/r_preset2.sh'
  rear_preset_3: '/home/hass/shell_scripts/r_preset3.sh'
  rear_preset_4: '/home/hass/shell_scripts/r_preset4.sh'

I’'m having all kinds of trouble trying to run a gitupdate.sh shell command. So far everything I have tried has resulted in failure!

Hmm same as mine except that I’ve tried with none like yours, bash and sudo bash at the front :stuck_out_tongue:

BTW I looked at who owns the file …
ls -l b*.sh
-rwxr-xr-x 1 homeassistant homeassistant 647 Feb 28 22:16 backup_config.sh

Hmm I had a thought does it matter who owns the directory I’m writing to?

I don’t think so. But hass owns my shell_script dir so you’re the same as me.

I think the problem is the usb thumb drive I’m trying to copy to, it’s that, that refuses permission to mv/cp the back.tgz file, however I don’t know how to solve that problem as it’s a windows formatted drive with only root privileges.

Shell Scripts:

backup_config.sh

#!/bin/bash

BACKUP_FILE=/media/pi/HASSUSB/hass-config_$(date +"%Y%m%d_%H%M%S").zip

pushd /home/homeassistant/.homeassistant >/dev/null
zip -9 -q -r $BACKUP_FILE . -x"components/*" -x"deps/*" -x"home-assistant.db" -x"home-assistant_v2.db" -x"home-assistant.log"
popd >/dev/null

echo Backup complete: $BACKUP_FILE

Shell Commands:

backup_config: /home/homeassistant/.homeassistant/shell_scripts/backup_config.sh

Automation:

- alias: Backup config
  hide_entity: True
  trigger:
    platform: time
    after: '03:00:00'
  action:
    service: shell_command.backup_config

That works for me perfect writes a backup everday at 3 AM.

Make sure you :

sudo chown homeassistant:homeassistant /media/pi/HASSUSB
sudo chmod 777 /media/pi/

Let me know.

Finally it works :smiley: It seems the shell command does not like the single quotes for .sh files, who knew! Many thanks for the help guys.

1 Like

Hi,
what path do I use if I am using Home Assistant in Synology Docker?
Thanks.