Hello everybody!
I’m trying to get this script working from Home assistant node-red without success:
The script works when manually executed frome command line.
the file has been chmod +x.
I have other scripts called the exact same way and i do no understant why this one dont.
#!/bin/bash
ssh -i "/config/scripts/id_rsa" -o StrictHostKeyChecking=no pi@hostname "sudo bash /home/pi/playlist_importer.sh"
Configuration.yaml looks like:
shell_command:
audio_shutdown: 'bash -c /config/scripts/audio_shutdown.sh'
playlist_exporter: 'bash -c /config/scripts/playlist_exporter.sh'
homeassistant_backup: 'bash -c /config/scripts/homeassistant_backup.sh'
Error code in HA looks like this:
## Log Details (ERROR)
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:97
Integration: shell_command ([documentation](https://www.home-assistant.io/integrations/shell_command), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+shell_command%22))
First occurred: 12:14:57 PM (1 occurrences)
Last logged: 12:14:57 PM
Error running command: `bash -c /config/scripts/playlist_exporter.sh`, return code: 126
NoneType: None
The called script looks like this:
#!/bin/bash
#installation if needed
if [[ $1 = "-i" ]]; then
echo "installing"
sudo apt-get install -y sshpass rename
if [ ! -d "/home/pi/imported_playlists" ]; then
mkdir "/home/pi/imported_playlists"
fi
fi
#----- Importation des playlists --------------------------------------------------------
echo "suppression des anciennes playlists"
rm -f /home/pi/imported_playlists/*
rm -f /var/lib/mpd/playlists/*
echo "importation des playlists"
sudo sshpass -p "password" sftp -o StrictHostKeyChecking=no "root@hostname:/sharedfolders/share/musique/playlists/* /home/pi/imported_playlists/"
echo "changement de repertoire"
cd /home/pi/imported_playlists/
echo "renommage et conversion:"
rename -f 's/.m3u8/.m3u/' *.m3u8
echo "Modification du chemin dans les playlists"
sed -i 's#/airsonic#NAS#g; s#music#Musique#g' *.m3u
echo "playlists renommées - copie dans le dossier d'exploitation"
cp -f /home/pi/imported_playlists/* /var/lib/mpd/playlists/
chmod -R 777 /var/lib/mpd/playlists/
chown mpd:audio /var/lib/mpd/playlists/*
echo "Mise a jour de la bibliotheque"
sleep 5
mpc update
Any hint appreciated !
Regards - JS