Script2 not executing Python line in shell script
DennisFury opened this issue · 2 comments
I've read through a ton of issues here, but can't find a fix.
In HomeKit, when I power on the accessory Script2 created, the "on" script does not execute the python line from the shell file, the shell ECHO line is coming through homebridge console, but the python script isn't executing.
Tried the following
- using full paths for everything, including python3 location
- chmod and chown the scripts to homebridge user, directory is 777'd
- homebridge user is apart of the sudoers group
- shell script runs fine from terminal, python script will execute as expected, just not w/ homebridge accessory
- restarted homebridge server several times (thinking it would need a reboot to realize new permissions)
config:
{
"accessory": "Script2",
"name": "Plex Script",
"on": "/home/pi/Scripts/on.sh",
"off": "/home/pi/Scripts/nothing.sh",
"state": "/home/pi/Scripts/state.sh",
"on_value": "true",
"unique_serial": "1234567"
}
file system:
pi@sirifluffer:~/Scripts $ pwd
/home/pi/Scripts
pi@sirifluffer:~/Scripts $ ls -la
total 24
drwxrwxrwx 2 pi pi 4096 May 17 18:34 .
drwxr-xr-x 20 pi pi 4096 May 17 18:30 ..
-rwxrwxrwx 1 homebridge sudo 457 May 17 17:45 on.py
-rwxrwxrwx 1 homebridge sudo 70 May 17 18:34 on.sh
-rwxrwxrwx 1 homebridge sudo 21 May 17 17:54 nothing.sh
-rwxrwxrwx 1 homebridge sudo 21 May 17 17:57 state.sh
On script -- "on.sh"
pi@sirifluffer:~/Scripts $ cat on.sh
#!/bin/sh
/usr/bin/python3 /home/pi/Scripts/on.py
echo "ON"
I fixed it. Here's the extra stuff I did if anyone else finds this and needs help.
The one troubleshooting step I didn't do was make sure "homebridge" user could run the script. When I tried to login to the user with "su homebridge". I first didn't know the password, so I setup a password with "passwd homebridge", then after that I would get the message that "This account is currently not available." That was because no shell was setup for user homebridge. To fix that, I did a "sudo nano /etc/passwd" and I set a shell for the homebridge user, it was set to /sbin/nologin, and I changed it to /bin/shell
Then I could login and I instantly figured out the problem when trying to run my python script.
I had a dependency / extra module needed that I originally installed with "pip3 install ". The problem with that was it only installed it for that one user (my "pi" user), so I installed it with "sudo pip3 install " then it was accessible for the homebridge user, and it's working great now, finally!
Thanks for documenting this for others to troubleshoot similar issues.