ASL3 cannot run external script

Trying to get SkyWarn Plus working in ASL3. Running into problems trying to get a DTMF function to run an external script.

841 = cmd,/usr/local/bin/SkywarnPlus/SkyDescribe.py 1 ; SkyDescribe the 1st alert

Checking the AllStar wiki, I cannot find ‘cmd’ in the functions list.

2 things to check.
Can you run this manually from the command line.
Normally you might find this a matter of ownership/permissions of the script file in question.

All permissions are set and I assume that Asterisk has root permission. I can run the script from the command line with sudo. Still no joy getting a DTMF function to fire the script.

-rwxr-xr-x 1 root root 12939 Apr 6 11:49 SkyDescribe.py

With ASL3, the “asterisk” process does NOT run as the “root” user. It runs as the “asterisk” user.

It always has run as -
USER: asterisk
GROUP: asterisk

But it also begs the question of your python user.

I created a simple script file to copy text to file in my home directory.

#!/bin/bash

echo test1234 > /home/n7jrr/test.out

Executable: -rwxr-xr-x 1 n7jrr n7jrr 52 Jul 14 17:36 test.sh

Defined the function in rpt.conf

[functions]

841 = cmd,/home/n7jrr/test.sh

And when I try to run *841 from a HT keypad or from Supermon… nothing. I cannot run an external script to run. This can’t this hard.

As I noted above, the “asterisk” process does NOT run as the “root” user. It runs as the “asterisk” user and does not have the “I can read/write any file” permissions. Your script looks to be writing into your own home directory and I’m guessing that it is not writable by the “asterisk” user.

Try your script again but, instead, write to “/tmp/test.out”.

I am following the instructions in setting up Skywarn Plus on ASL3. Of course, there is nothing in the instructions on setting the proper permissions. I just banging my head against the wall trying to get this to work. So far all I have is a headache and the wall is not looking too good either.

I have SkywarnPlus installed on one of my nodes and I just followed the written instructions. All just worked (for me).

Here, it looks like you are experimenting with app_rpt “functions”. Yes, there’s a bit of learning curve re: where to put files and executables, filesystem permissions, etc. But, once you’ve got everything in place you should be good.

As for SkywarnPlus, have you seen this video :

SkywarnPlus author here. I’ve looked into this and have found the issue to in fact be permissions based and only applied only to ASL3 installations - where Asterisk 20 no longer runs as the root user.

The main SkywarnPlus.py script does not have an issue running, because pretty much everyone adds it to the crontab while logged in as root - thus the main script is always executed from roots crontab.

However, the SkyDescribe.py and SkyControl.py scripts are normally added as functions to rpt.conf, and are thus executed by Asterisk as the asterisk user. The asterisk user does not have permission to access any files owned/created by the root user. This can be seen when manually executing the scripts as the asterisk user:

root@ASL3:~# sudo -u asterisk /usr/local/bin/SkywarnPlus/SkyDescribe.py 1
Traceback (most recent call last):
  File "/usr/local/bin/SkywarnPlus/SkyDescribe.py", line 82, in <module>
    FH = logging.FileHandler(LOG_PATH)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/usr/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/tmp/SkywarnPlus/SkyDescribe.log'
root@ASL3:~# sudo -u asterisk /usr/local/bin/SkywarnPlus/SkyControl.py enable toggle
Traceback (most recent call last):
  File "/usr/local/bin/SkywarnPlus/SkyControl.py", line 234, in <module>
    with open(str(CONFIG_FILE), "w") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/SkywarnPlus/config.yaml'

A possible workaround could be to add asterisk as a passwordless sudoer, and simply place sudo in front of any SWP functions in rpt.conf - but this is less than ideal for obvious reasons.

Is there any technical reason to run this as root? Running as the asterisk user throughout seems like it would solve this issue?

You are correct, I was completely overthinking it.

I just updated the official SkywarnPlus installation instructions for ASL3 compatibility. For users that have already installed SkywarnPlus on their ASL3 node, the “patch” is as follows:

  1. Modify existing crontab entry to execute SkywarnPlus as the asterisk user:

    # Run `crontab -e` and insert 'asterisk' into the line as shown
    * * * * * asterisk /usr/local/bin/SkywarnPlus/SkywarnPlus.py
    
  2. Alter permissions:

    chown -R asterisk:asterisk /usr/local/bin/SkywarnPlus/
    chmod -R u+rwx /usr/local/bin/SkywarnPlus/
    
  3. Clear SWP cache:

    rm -rf /tmp/SkywarnPlus/
    

After these quick modifications, there should be no issues executing any of the SWP scripts on ASL3.

1 Like

Great news. I’d be interested in helping you package this as a Debian .deb package for ASL3.

I do not know what I am doing wrong. I followed the instructions step by step. I still cannot get SkyDescribe.py to launch using DTMF commands either through Supermon or a keypad on a radio. SkyDescribe.py works fine from the command line.

Has anyone gotten the scripts to run via DTMF? If anyone has been successful, could you post your rpt.conf file?

Did you reinstall SkywarnPlus using the new installer and/or new manual installation instructions? The asterisk user must have the correct permissions for the scripts to work properly on ASL3. The new SkywarnPlus installer will assist you in making sure SkywarnPlus is installed properly so that asterisk is able to access the files.

I did all the above you mentioned here, but I still show a Heat Advisory, where my HamVoip isn’t.

Any other suggestions? I did everything you mentioned, then rebooted the server.

Thank you

This thread, and the steps I mentioned above, have nothing to do with that particular distribution you are running. We are discussing ASL3 here.

The information on your Supermon page is not coming from SkywarnPlus. SkywarnPlus will append the county after the alert title, like:

Heat Advisory [Pulaski]

Make sure you do not have AutoSkywarn or AUTOSKY installed.

FYI, this is on ASL3 :slight_smile:

I installed from the script in your Github as well.

I can manually delete everything from SkywarnPlus directory and do the automatic install again.

Of course copy my config.yaml file first if this might be best?

EL AWL BE MR DUCKS

It’s works. I did a fresh install of ASL from image and ran ‘the script’ to install SkywarnPlus. DTMF is working from the HT keypad and Supermon. Now I can safely visit Yellowstone monitoring for Volcano Alerts.

(It’s always a permissions issue with Linux, en-it?)

73 de N7JRR