Re: Correct pexp variable for a shell script

2019-06-29 Thread Jacob Adams


On 6/29/19 8:46 AM, Antoine Jacoutot wrote:
> On Sat, Jun 22, 2019 at 02:14:12PM -0400, Jacob Adams wrote:
>> On 6/22/19 12:43 PM, Antoine Jacoutot wrote:
>>> On Sat, Jun 22, 2019 at 10:42:39AM -0400, Jacob Adams wrote:
 On 6/22/19 7:05 AM, Antoine Jacoutot wrote:
> On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
>> I've got a shell script I'd like to run as a system service. Due to the
>> 16 character limitation on pgrep and the -x flag that rc.subr passes to
>> check by default, I can't get check or stop to work correctly. The
>> problem is that the process name looks like "/bin/sh
>> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
>> when -x is used.
>>
>> My rc.d script currently looks like this:
>>
> Hi.
>
> That should not be an issue, that's why pexp is used for.
> But without more context it's hard to know how to help you.
>
> I can match sh scripts without issue:
> $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
> 77289
>
> Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
> We don't run into the 16 chars  limitation when using -xf
 Here's what I was seeing that led me to that conclusion:

 rukey$ ps aux | grep authmail
 root 51889  0.0  0.1   724   568 p0- Ip    Fri12AM    0:00.01
 /bin/sh /usr/local/bin/authmail
 jacob    25510  0.0  0.2   272   892 p0  S+p   10:36AM    0:00.01 grep
 authmail
 rukey$ pgrep -f /bin/sh /usr/local/bin/authmail
 51889
 rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail


 However, I didn't think to quote it. that seems to fix it:

 rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail"
 51889

 It appears that rc.subr uses quotes, but:

 rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail"
 51889
 rukey# rcctl check authmail
 authmail(failed)
 rukey#

 Any idea what could be going wrong here?
>>> Dunno, run rcctl in debug mode.
>>
>> rukey# ps ux | grep authmail
>> root 93772  0.0  0.2   272   892 p0  S+p    2:10PM    0:00.01 grep
>> authmail
>> rukey# rcctl -d start authmail
>> doing _rc_parse_conf
>> doing _rc_quirks
>> authmail_flags empty, using default ><
>> doing _rc_parse_conf /var/run/rc.d/authmail
>> doing _rc_quirks
>> doing rc_check
>> authmail
>> doing rc_start
>> doing _rc_wait start
>> doing rc_check
>> doing rc_check
> Can you share you /var/run/rc.d/authmail file please.


That seems to be the problem


daemon_class=daemon
daemon_flags=
daemon_rtable=0
daemon_timeout=30
daemon_user=root
pexp=/usr/local/bin/authmail.sh


Deleting that file and restarting authmail fixed the issue, allowing me
to start authmail successfully


Thanks for your help!


Jacob



Re: Correct pexp variable for a shell script

2019-06-29 Thread Antoine Jacoutot
On Sat, Jun 22, 2019 at 02:14:12PM -0400, Jacob Adams wrote:
> 
> On 6/22/19 12:43 PM, Antoine Jacoutot wrote:
> > On Sat, Jun 22, 2019 at 10:42:39AM -0400, Jacob Adams wrote:
> >> On 6/22/19 7:05 AM, Antoine Jacoutot wrote:
> >>> On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
>  I've got a shell script I'd like to run as a system service. Due to the
>  16 character limitation on pgrep and the -x flag that rc.subr passes to
>  check by default, I can't get check or stop to work correctly. The
>  problem is that the process name looks like "/bin/sh
>  /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
>  when -x is used.
> 
>  My rc.d script currently looks like this:
> 
> >>> Hi.
> >>>
> >>> That should not be an issue, that's why pexp is used for.
> >>> But without more context it's hard to know how to help you.
> >>>
> >>> I can match sh scripts without issue:
> >>> $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
> >>> 77289
> >>>
> >>> Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
> >>> We don't run into the 16 chars  limitation when using -xf
> >>
> >> Here's what I was seeing that led me to that conclusion:
> >>
> >> rukey$ ps aux | grep authmail
> >> root 51889  0.0  0.1   724   568 p0- Ip    Fri12AM    0:00.01
> >> /bin/sh /usr/local/bin/authmail
> >> jacob    25510  0.0  0.2   272   892 p0  S+p   10:36AM    0:00.01 grep
> >> authmail
> >> rukey$ pgrep -f /bin/sh /usr/local/bin/authmail
> >> 51889
> >> rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail
> >>
> >>
> >> However, I didn't think to quote it. that seems to fix it:
> >>
> >> rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail"
> >> 51889
> >>
> >> It appears that rc.subr uses quotes, but:
> >>
> >> rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail"
> >> 51889
> >> rukey# rcctl check authmail
> >> authmail(failed)
> >> rukey#
> >>
> >> Any idea what could be going wrong here?
> > Dunno, run rcctl in debug mode.
> 
> 
> rukey# ps ux | grep authmail
> root 93772  0.0  0.2   272   892 p0  S+p    2:10PM    0:00.01 grep
> authmail
> rukey# rcctl -d start authmail
> doing _rc_parse_conf
> doing _rc_quirks
> authmail_flags empty, using default ><
> doing _rc_parse_conf /var/run/rc.d/authmail
> doing _rc_quirks
> doing rc_check
> authmail
> doing rc_start
> doing _rc_wait start
> doing rc_check
> doing rc_check

Can you share you /var/run/rc.d/authmail file please.

-- 
Antoine



Re: Correct pexp variable for a shell script

2019-06-25 Thread Fernando Braga
Or maybe

ps | grep [a]uthmail



Em ter, 25 de jun de 2019 às 14:42, Chris Bennett <
cpb_m...@bennettconstruction.us> escreveu:

> On Sat, Jun 22, 2019 at 02:14:12PM -0400, Jacob Adams wrote:
> >
> > rukey# ps | grep authmail
> > 17035 p0  Ip  0:00.01 /bin/sh /usr/local/bin/authmail
> > 25162 p0  R+p 0:00.01 grep authmail
> > rukey#
> >
> ps | grep authmail | grep -v grep  ??
>
> Chris Bennett
>
>
>


Re: Correct pexp variable for a shell script

2019-06-25 Thread Chris Bennett
On Sat, Jun 22, 2019 at 02:14:12PM -0400, Jacob Adams wrote:
> 
> rukey# ps | grep authmail
> 17035 p0  Ip  0:00.01 /bin/sh /usr/local/bin/authmail
> 25162 p0  R+p 0:00.01 grep authmail
> rukey#
> 
ps | grep authmail | grep -v grep  ??

Chris Bennett




Re: Correct pexp variable for a shell script

2019-06-22 Thread Jacob Adams


On 6/22/19 12:43 PM, Antoine Jacoutot wrote:
> On Sat, Jun 22, 2019 at 10:42:39AM -0400, Jacob Adams wrote:
>> On 6/22/19 7:05 AM, Antoine Jacoutot wrote:
>>> On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
 I've got a shell script I'd like to run as a system service. Due to the
 16 character limitation on pgrep and the -x flag that rc.subr passes to
 check by default, I can't get check or stop to work correctly. The
 problem is that the process name looks like "/bin/sh
 /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
 when -x is used.

 My rc.d script currently looks like this:

>>> Hi.
>>>
>>> That should not be an issue, that's why pexp is used for.
>>> But without more context it's hard to know how to help you.
>>>
>>> I can match sh scripts without issue:
>>> $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
>>> 77289
>>>
>>> Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
>>> We don't run into the 16 chars  limitation when using -xf
>>
>> Here's what I was seeing that led me to that conclusion:
>>
>> rukey$ ps aux | grep authmail
>> root 51889  0.0  0.1   724   568 p0- Ip    Fri12AM    0:00.01
>> /bin/sh /usr/local/bin/authmail
>> jacob    25510  0.0  0.2   272   892 p0  S+p   10:36AM    0:00.01 grep
>> authmail
>> rukey$ pgrep -f /bin/sh /usr/local/bin/authmail
>> 51889
>> rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail
>>
>>
>> However, I didn't think to quote it. that seems to fix it:
>>
>> rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail"
>> 51889
>>
>> It appears that rc.subr uses quotes, but:
>>
>> rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail"
>> 51889
>> rukey# rcctl check authmail
>> authmail(failed)
>> rukey#
>>
>> Any idea what could be going wrong here?
> Dunno, run rcctl in debug mode.


rukey# ps ux | grep authmail
root 93772  0.0  0.2   272   892 p0  S+p    2:10PM    0:00.01 grep
authmail
rukey# rcctl -d start authmail
doing _rc_parse_conf
doing _rc_quirks
authmail_flags empty, using default ><
doing _rc_parse_conf /var/run/rc.d/authmail
doing _rc_quirks
doing rc_check
authmail
doing rc_start
doing _rc_wait start
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
doing rc_check
Alarm clock
/etc/rc.d/authmail: kill: 73440: No such process
doing _rc_write_runfile
(ok)
rukey# rcctl -d check authmail
doing _rc_parse_conf
doing _rc_quirks
authmail_flags empty, using default ><
doing _rc_parse_conf /var/run/rc.d/authmail
doing _rc_quirks
authmail
doing rc_check
(failed)
rukey# ps | grep authmail
17035 p0  Ip  0:00.01 /bin/sh /usr/local/bin/authmail
25162 p0  R+p 0:00.01 grep authmail
rukey#



Re: Correct pexp variable for a shell script

2019-06-22 Thread Antoine Jacoutot
On Sat, Jun 22, 2019 at 10:42:39AM -0400, Jacob Adams wrote:
> 
> On 6/22/19 7:05 AM, Antoine Jacoutot wrote:
> > On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
> >> I've got a shell script I'd like to run as a system service. Due to the
> >> 16 character limitation on pgrep and the -x flag that rc.subr passes to
> >> check by default, I can't get check or stop to work correctly. The
> >> problem is that the process name looks like "/bin/sh
> >> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
> >> when -x is used.
> >>
> >> My rc.d script currently looks like this:
> >>
> > Hi.
> >
> > That should not be an issue, that's why pexp is used for.
> > But without more context it's hard to know how to help you.
> >
> > I can match sh scripts without issue:
> > $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
> > 77289
> >
> > Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
> > We don't run into the 16 chars  limitation when using -xf
> 
> 
> Here's what I was seeing that led me to that conclusion:
> 
> rukey$ ps aux | grep authmail
> root 51889  0.0  0.1   724   568 p0- Ip    Fri12AM    0:00.01
> /bin/sh /usr/local/bin/authmail
> jacob    25510  0.0  0.2   272   892 p0  S+p   10:36AM    0:00.01 grep
> authmail
> rukey$ pgrep -f /bin/sh /usr/local/bin/authmail
> 51889
> rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail
> 
> 
> However, I didn't think to quote it. that seems to fix it:
> 
> rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail"
> 51889
> 
> It appears that rc.subr uses quotes, but:
> 
> rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail"
> 51889
> rukey# rcctl check authmail
> authmail(failed)
> rukey#
> 
> Any idea what could be going wrong here?

Dunno, run rcctl in debug mode.

-- 
Antoine



Re: Correct pexp variable for a shell script

2019-06-22 Thread Jacob Adams


On 6/22/19 7:05 AM, Antoine Jacoutot wrote:
> On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
>> I've got a shell script I'd like to run as a system service. Due to the
>> 16 character limitation on pgrep and the -x flag that rc.subr passes to
>> check by default, I can't get check or stop to work correctly. The
>> problem is that the process name looks like "/bin/sh
>> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
>> when -x is used.
>>
>> My rc.d script currently looks like this:
>>
> Hi.
>
> That should not be an issue, that's why pexp is used for.
> But without more context it's hard to know how to help you.
>
> I can match sh scripts without issue:
> $ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
> 77289
>
> Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
> We don't run into the 16 chars  limitation when using -xf


Here's what I was seeing that led me to that conclusion:

rukey$ ps aux | grep authmail
root 51889  0.0  0.1   724   568 p0- Ip    Fri12AM    0:00.01
/bin/sh /usr/local/bin/authmail
jacob    25510  0.0  0.2   272   892 p0  S+p   10:36AM    0:00.01 grep
authmail
rukey$ pgrep -f /bin/sh /usr/local/bin/authmail
51889
rukey$ pgrep -xf /bin/sh /usr/local/bin/authmail


However, I didn't think to quote it. that seems to fix it:

rukey$ pgrep -xf "/bin/sh /usr/local/bin/authmail"
51889

It appears that rc.subr uses quotes, but:

rukey# pgrep -xf "/bin/sh /usr/local/bin/authmail"
51889
rukey# rcctl check authmail
authmail(failed)
rukey#

Any idea what could be going wrong here?


Thanks,
Jacob




Re: Correct pexp variable for a shell script

2019-06-22 Thread Antoine Jacoutot
On Fri, Jun 21, 2019 at 03:57:41PM -0400, Jacob Adams wrote:
> I've got a shell script I'd like to run as a system service. Due to the
> 16 character limitation on pgrep and the -x flag that rc.subr passes to
> check by default, I can't get check or stop to work correctly. The
> problem is that the process name looks like "/bin/sh
> /usr/local/bin/script.sh" which, even if passed to pgrep, won't match
> when -x is used.
> 
> My rc.d script currently looks like this:
> 

Hi.

That should not be an issue, that's why pexp is used for.
But without more context it's hard to know how to help you.

I can match sh scripts without issue:
$ pgrep -xf "/bin/sh /etc/gdm/Xsession /usr/local/bin/gnome-session"
77289

Are you sure your entire process line is "bin/sh /usr/local/bin/authmail"?
We don't run into the 16 chars  limitation when using -xf


> #!/bin/ksh
> 
> AUTHMAIL="/usr/local/bin/authmail"
> daemon=${AUTHMAIL}
> daemon_timeout=1
> 
> . /etc/rc.d/rc.subr
> 
> rc_reload=NO
> rc_bg=YES
> pexp="/bin/sh ${AUTHMAIL}"
> 
> rc_cmd $1
> 
> Do I have any other options, or do I just need to override rc_check to
> remove -x?
> 
> 

-- 
Antoine



Correct pexp variable for a shell script

2019-06-21 Thread Jacob Adams
I've got a shell script I'd like to run as a system service. Due to the
16 character limitation on pgrep and the -x flag that rc.subr passes to
check by default, I can't get check or stop to work correctly. The
problem is that the process name looks like "/bin/sh
/usr/local/bin/script.sh" which, even if passed to pgrep, won't match
when -x is used.

My rc.d script currently looks like this:

#!/bin/ksh

AUTHMAIL="/usr/local/bin/authmail"
daemon=${AUTHMAIL}
daemon_timeout=1

. /etc/rc.d/rc.subr

rc_reload=NO
rc_bg=YES
pexp="/bin/sh ${AUTHMAIL}"

rc_cmd $1

Do I have any other options, or do I just need to override rc_check to
remove -x?