Problem with getting /bin/su - -c to work


Brian
 

Hello,
 
I am trying to start a process called ctone when my node starts.  I place the following lines either at the end of rc.local or rc.irlp and the 2nd line doesn't seem to load.
 
killall ctone
/bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
 
When I enter this line manually as root and check the process afterward, this is what I get:
 
root@stn7505:~# /bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
[1] 17028
root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
[1]+  Exit 127                /bin/su - -c "$CUSTOM"/ctone repeater &> /dev/null
root@stn7505:~#
 
It works when I log in as repeater and manually enter it.
 
repeater@stn7505:~/$ "$CUSTOM/ctone" &>/dev/null &
[1] 14737
repeater@stn7505:~/$ ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater 14737 14176  1 18:58 pts/2    00:00:00 /usr/bin/perl -w /home/irlp/cust
repeater@stn7505:~/$
 
 
I've done this with other nodes I manage and it works fine.  This is a Pi running Jessie.
 
Thanks for any help,
73 
Brian - K1SOX


pclark36 <pclark36@...>
 

Brian,

If you are running that as root,  It does not appear that $CUSTOM has been set in the root env variable.  You need to set that variable first. 

Thanks,

PC


On Mon, Dec 28, 2020 at 3:15 PM Brian <k1sox@...> wrote:
Hello,
 
I am trying to start a process called ctone when my node starts.  I place the following lines either at the end of rc.local or rc.irlp and the 2nd line doesn't seem to load.
 
killall ctone
/bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
 
When I enter this line manually as root and check the process afterward, this is what I get:
 
root@stn7505:~# /bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
[1] 17028
root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
[1]+  Exit 127                /bin/su - -c "$CUSTOM"/ctone repeater &> /dev/null
root@stn7505:~#
 
It works when I log in as repeater and manually enter it.
 
repeater@stn7505:~/$ "$CUSTOM/ctone" &>/dev/null &
[1] 14737
repeater@stn7505:~/$ ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater 14737 14176  1 18:58 pts/2    00:00:00 /usr/bin/perl -w /home/irlp/cust
repeater@stn7505:~/$
 
 
I've done this with other nodes I manage and it works fine.  This is a Pi running Jessie.
 
Thanks for any help,
73 
Brian - K1SOX


WD5M David M.
 

Why not use /home/irlp/custom/rc.irlp for these processes. Note, rc.irlp is owned by root, so edit it with root. Make a backup copy too.

David M.
WD5M


On Mon, Dec 28, 2020 at 6:15 PM Brian <k1sox@...> wrote:
Hello,
 
I am trying to start a process called ctone when my node starts.  I place the following lines either at the end of rc.local or rc.irlp and the 2nd line doesn't seem to load.
 
killall ctone
/bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
 
When I enter this line manually as root and check the process afterward, this is what I get:
 
root@stn7505:~# /bin/su - -c "$CUSTOM"/ctone repeater &>/dev/null &
[1] 17028
root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
[1]+  Exit 127                /bin/su - -c "$CUSTOM"/ctone repeater &> /dev/null
root@stn7505:~#
 
It works when I log in as repeater and manually enter it.
 
repeater@stn7505:~/$ "$CUSTOM/ctone" &>/dev/null &
[1] 14737
repeater@stn7505:~/$ ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater 14737 14176  1 18:58 pts/2    00:00:00 /usr/bin/perl -w /home/irlp/cust
repeater@stn7505:~/$
 
 
I've done this with other nodes I manage and it works fine.  This is a Pi running Jessie.
 
Thanks for any help,
73 
Brian - K1SOX


Brian
 

Hi pclark,

Adding CUSTOM to env did get the process to run when I rebooted the node:

root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater   848   837 14 20:05 ?        00:00:00 /usr/bin/perl -w /home/irlp/cust
root@stn7505:~#

However, the ctone script still isn't working correctly and it does when I start it manually under user repeater.  Also I noticed that on the other node I used this on, it didn't have CUSTOM in the env file for root and it works fine.  I could be wrong, but isn't the whole point of the " - -c" in the su command to use the environmental variables of the substitute user?

I might have to try to contact the author of the ctone script if they are still around.  The point of the script is to generate a courtesy tone on the RF side when a user unkeys from IRLP.  When I put this in the rc.irlp file, it only plays the tone once and then stops working even though the process continues to show it's running.  However, when I manually start it as repeater, if works continuously with not issues.  Obviously, I don't want to have to start the script manually every time I reboot the node :)

Thanks for any input.

Brian


Brian
 

Hi Dave,

Tried that, same issue.  Yes I did edit with root.

It's so strange, the script works properly when run as repeater directly but when trying to su it, it give issues and has these problems on this node.  My other node, 4663, it works fine.

If you have any other ideas, I'll give them a try.

Thanks


Brian
 

Dave,

Looks like this is your script.  Thank you for writing this.  Very useful.  Hope I can get this figured out.

Brian


pclark36 <pclark36@...>
 

Brian,

'su - ' forces you to root variables and directories.  If you wanted to use the user repeater use 'su - repeater -c' to pass on  the user repeater variables.


On Mon, Dec 28, 2020 at 4:17 PM Brian <k1sox@...> wrote:
Hi pclark,

Adding CUSTOM to env did get the process to run when I rebooted the node:

root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater   848   837 14 20:05 ?        00:00:00 /usr/bin/perl -w /home/irlp/cust
root@stn7505:~#

However, the ctone script still isn't working correctly and it does when I start it manually under user repeater.  Also I noticed that on the other node I used this on, it didn't have CUSTOM in the env file for root and it works fine.  I could be wrong, but isn't the whole point of the " - -c" in the su command to use the environmental variables of the substitute user?

I might have to try to contact the author of the ctone script if they are still around.  The point of the script is to generate a courtesy tone on the RF side when a user unkeys from IRLP.  When I put this in the rc.irlp file, it only plays the tone once and then stops working even though the process continues to show it's running.  However, when I manually start it as repeater, if works continuously with not issues.  Obviously, I don't want to have to start the script manually every time I reboot the node :)

Thanks for any input.

Brian


pclark36 <pclark36@...>
 

Brian,

I will let Dave help you with this as I'm looking at this from a straight linux standpoint, sounds like Dave knows the ins and outs better.    


On Mon, Dec 28, 2020 at 4:25 PM Patrick Clark <pclark36@...> wrote:
Brian,

'su - ' forces you to root variables and directories.  If you wanted to use the user repeater use 'su - repeater -c' to pass on  the user repeater variables.

On Mon, Dec 28, 2020 at 4:17 PM Brian <k1sox@...> wrote:
Hi pclark,

Adding CUSTOM to env did get the process to run when I rebooted the node:

root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater   848   837 14 20:05 ?        00:00:00 /usr/bin/perl -w /home/irlp/cust
root@stn7505:~#

However, the ctone script still isn't working correctly and it does when I start it manually under user repeater.  Also I noticed that on the other node I used this on, it didn't have CUSTOM in the env file for root and it works fine.  I could be wrong, but isn't the whole point of the " - -c" in the su command to use the environmental variables of the substitute user?

I might have to try to contact the author of the ctone script if they are still around.  The point of the script is to generate a courtesy tone on the RF side when a user unkeys from IRLP.  When I put this in the rc.irlp file, it only plays the tone once and then stops working even though the process continues to show it's running.  However, when I manually start it as repeater, if works continuously with not issues.  Obviously, I don't want to have to start the script manually every time I reboot the node :)

Thanks for any input.

Brian


Brian
 

Thanks pclark,

Dave, I changed CUSTOM\ctone to "home\irlp\custom\ctone" in the rc.irlp and it shows the process is started and
running.
root@stn7505:~# ps -fC ctone
UID        PID  PPID  C STIME TTY          TIME CMD
repeater   841   830  0 20:57 ?        00:00:00 /usr/bin/perl -w /home/irlp/cust
root@stn7505:~#
The problem now is the ctone only only plays ONCE and never again until I reboot the node.

I boot the node, connect to ref 9990 and get the announcement saying I'm connected and then my ct.wav plays.  That's it, no matter what I do, echo tests, disconnect and re-connect to reflector, no tone.  If I reboot, it plays one time again.

If I type killall ctone under root session and then go under repeater session and type "$CUSTOM/ctone" &>/dev/null &, it works fine with no issues.  I need that to start automatically.  

Any ideas?  Thanks