Issues getting shell commands/scripts to work

I’ve been trying to figure out what I’m doing wrong for quite some time now, I’ll try to post anything related to it, but please ask if you need more info

Configuration.yaml

https://github.com/martikainen87/HomeAssistant/blob/master/configuration.yaml

/home/homeassistant/shell_commands.yaml

I’ve installed HA in virtual environment according to Installation - Home Assistant
and everything else is working like a charm! :slight_smile:
The script ‘plexmount.sh’ can be executed via ssh with both my homeassistant user and default “pi”, i’ve tried placing the .sh script in different folders /home/pi/, /home/.homeassistant/shell_commands/ ) and made sure that they have full priviligies during the testing.

running it in ssh console

both users “homeassistant” (the user running HA) and “pi” has full access
script works (it connects to another linux server and tries to mount some folders, they are already mounted as you can see) with both users

pi@hassbian:/home/homeassistant $ sh plexmount.sh
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
pi@hassbian:/home/homeassistant $ sudo su -s /bin/bash homeassistant
homeassistant@hassbian:~ $ sh plexmount.sh
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option

dev-services

I can execute the shell command /dev-service by chosing
Domain: shell_command
service: plex_mount_drives

auth.log at other server after executing it from /dev-service

Mar 2 16:09:13 Plexi sshd[8433]: Accepted password for homeassistant from 192.168.1.4 port 48626 ssh2
Mar 2 16:09:13 Plexi sshd[8433]: pam_unix(sshd:session): session opened for user homeassistant by (uid=0)
Mar 2 16:09:13 Plexi systemd-logind[1230]: New session 18 of user homeassistant.
Mar 2 16:09:13 Plexi sshd[8478]: Received disconnect from 192.168.1.4 port 48626:11: disconnected by user
Mar 2 16:09:13 Plexi sshd[8478]: Disconnected from 192.168.1.4 port 48626
Mar 2 16:09:13 Plexi sshd[8433]: pam_unix(sshd:session): session closed for user homeassistant
Mar 2 16:09:13 Plexi systemd-logind[1230]: Removed session 18.

but no matter what i try i can’t get the script to execute the shell_command from the web front. I’ve tried setting single quoutes ’ ’ for the location of the script, like this plex_mount_drives: ‘/home/homeassistant/plexmount.sh’

All my config is available at github, https://github.com/martikainen87/HomeAssistant if you wanna take a look

Any suggestion?

Have you tried executing the script when you’re “inside” the virtual environment? If the shell script requires any outside libraries, they need to be installed inside the venv.

The command to enter the venv will be something like
source /srv/hass/hass_venv/bin/activate
(path will depend on your install)

Thanks for the quick attention ih8gates!

Hadn’t tried that one but it didnt show anything useful i guess =/

Last login: Thu Mar 2 15:13:28 2017 from desktop-4n3albb
pi@hassbian:~ $ sudo su -s /bin/bash homeassistant
homeassistant@hassbian:/home/pi $ source /srv/homeassistant/bin/activate
(homeassistant) homeassistant@hassbian:/home/pi $ sh /home/homeassistant/plexmount.sh
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the ‘nonempty’ mount option
(homeassistant) homeassistant@hassbian:/home/pi $

Script works fine when I’m in it, I guess there’s something wrong with the “script” configuration, since I am able to call the mount.sh script from the /dev-services, but I cant run it by clicking in the web-gui.

Ah, OK. So it works fine when called through the services tool but not when you click on the link in the web UI. That’s really weird since they should be doing the same thing. It should either work for both or fail for both.

Out of curiosity, have you tried looking at the developer tools in your web browser (F12) to watch the network traffic when you execute the shell command from the UI? That might shed some light on the situation.

s:r

I have the same problem… No solution?