Running APRS iGate while idle, PRE script won't kill direwolf and rtl_fm

Hello all! I was wondering if someone could help me out.
I have two separate satnog stations. A UHF and a VHF station.
While idle, I would like for them to act as APRS iGates.
I have the POST_OBSERVATION_SCRIPT working just fine that starts rtl_fm and direwolf after the observation and functions great as an APRS iGate.
The problem I’m having is with the PRE_OBSERVATION_SCRIPT killing the apps before the observation. It doesn’t seem to want to kill the programs. I can run the script on the command line as the pi user and both of the applications close just fine.
I have added the satnogs user to the pi group in case that was the issue, but it’s not working either.

Here is my PRE_OBSERVATION_SCRIPT to kill rtl_fm and direwolf
.
/usr/local/bin/
-rwxr-xr-x 1 pi pi 97 Mar 24 16:31 vhfigatestop.sh

/usr/local/bin/vhfigatestop.sh
#!/bin/bash
#killall direwolf rtl_fm
sudo kill $(pgrep -f direwolf)
sudo kill $(pgrep -f rtl_fm)

Here is my POST_OBSERVATION_SCRIPT to start the iGate

/usr/local/bin/
-rwxr-xr-x 1 pi pi 123 Mar 25 08:42 vhfigatestart.sh

/usr/local/bin/vhfigatestart.sh
#!/bin/bash
rtl_fm -f 144.39M -M fm -s 200000 -r 32000 -p 100 | direwolf -c /home/pi/igate.conf -n 1 -r 32000 -b 16 -t 0 -

Here is a diagram I worked up to help me perhaps see where my issue might be.

Here is a view of how I’m monitoring if the scripts are run. You can see on the left (vhf) station that it’s in the middle of an observation and direwolf and rtl_fm are still running.

Thanks for any help!

Adam - KD5QZG

EDIT: this below did not work. It worked when I manually started up the igate start script from the command line as the pi user and let the post script kill it, but when I let satnogs launch the igate start script using the post script, the pre script would not kill it again… sigh.

===============================
I may have gotten it to work!!!
I switched the script back to killall instead of the kill/pgrep part.

I did the following in a root bash console.

I ran:
sudo visudo

I added this to the last line:
satnogs ALL = NOPASSWD: /usr/local/bin/vhfigatestop.sh, /usr/local/bin/vhfigatestart.sh, /usr/bin/killall

It now seems to be working!!!

So I guess it was a sudo issue with the satnogs user and it just needed elevated permissions for the killall command.

Big thanks to the following links that helped me get the rest of the way!

I did however notice that when the post script runs to start the igate, it launches as the satnogs user.Which makes it even stranger that the pre script is not killing it.

satnogs   6529  0.0  0.0   1940   416 ?        S    10:39   0:00 sh /usr/local/bin/vhfigatestart.sh
satnogs   6530 60.6  0.3  61256  3136 ?        Sl   10:39  13:45 rtl_fm -f 144.39M -M fm -s 200000 -r 32000 -p 100
satnogs   6531  8.7  0.4 103840  4572 ?        Sl   10:39   1:59 direwolf -c /home/pi/igate.conf -n 1 -r 32000 -b 16 -t 0 -