gammu-smsd is not executing RunOnReceive script

402 views Asked by At

I am working on a RaspberryPi with latest RaspbianOS. Gammu-smsd in the latest version available installed on the Pi. I can send and receive SMS via gammu-smsd fine. I am trying to run a file that ssh`s (using sshpass) into a remote Ubuntu machine and calls a python script on the remote machine. I set up the gammu config file "/etc/gammu-smsdrc" on the Pi like so:

# Gammu library configuration, see gammurc(5)
[gammu]
# Please configure this!
port = /dev/ttyS0
connection = at
# Debugging
#logformat = textall

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = files
logfile = syslog
# Increase for debugging information
debuglevel = 2
PIN = 3831
RunOnReceive = /home/pi/run.sh

# Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/
errorsmspath = /var/spool/gammu/error/

The file that should being run on receive, for testing has 777 rights and belongs to user pi, group pi. The file runs when called as user 'pi' from cli via "./run.sh" fine with no errors. Also running the content of the 'run.sh' file pasted below, runs fine as user 'pi' and kicks off the python script on the remote Ubuntu machine fine without any errors. The contents of 'run.sh' are:

#!/bin/sh
/usr/bin/sshpass -p "MY_PASSWORD" ssh [email protected] "/usr/bin/python3 /home/thomas/anydir/grkrt/pshvr.py"

I assume that it has something to do with users and rights but my Unix skills are too limited investigating this any further and it cost me 2 days investigating. The script 'run.sh' is being called from gammu when a SMS is received, so I assume the user calling the script 'run.sh' is gammu. When I call the script via running './run.sh' in the context of the standard 'pi' user the script runs fine.

In gammu syslogs I can see that the script is called (at least I am getting no error on this) when a SMS is received but the commands are not executed on the remote server. I thought that sshpass'ing as a distinct user into a remote machine overrides the users permission who is executing the script. Not sure if i make my point clear here.

User gammu is calling the script 'run.sh' on a RaspberryPi where I am sshpass'ing as user 'thomas' into a remote Ubuntu machine and executing a python script, and I thought that sshpass'ing as a user would give me the rights on the remote machine for the user i am logging in ? But something is not working or I am missing something...

Any hint would be widely appreciated ...

1

There are 1 answers

2
t.jirku On

got it solved via a workaround with a curl command. I am calling a curl command via RunOnReceive directive in the gammu-smsdrc config file - that works without issues and no issues with userrights so far. the curl command sets a value in my ubuntu iobroker installation that finally triggers a javascript via blockly and runs the python script on another ubuntu machine without any flaws. not the most straight forward but working stable so far.