rc scripts

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

rc scripts

Ian McWilliam-2
Hi all,

Need some advice on the rc script infrastructure and the best way to detect running processes.

is some like the following acceptable practice or are there some existing functions that will do the
equivalent.

rc_pre() {
    pgrep -fq "${TRUEPREFIX}/bin/samba"
    if [[ $? == 0 ]]; then
         rc_err "$0: Cannot run while AD Server Running"
    fi
}

Secondly is it acceptable to create a common rc script to hold common subs used amongst multiple rc
script for a port, eg samba.subr that will be used by smbd and nmbd rc scripts?

Any thoughts / ideas appreciated.

--
Ian McWilliam

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Antoine Jacoutot-7
On Thu, Jul 03, 2014 at 02:13:46PM +1000, Ian McWilliam wrote:

> Hi all,
>
> Need some advice on the rc script infrastructure and the best way to detect running processes.
>
> is some like the following acceptable practice or are there some existing functions that will do the
> equivalent.
>
> rc_pre() {
>     pgrep -fq "${TRUEPREFIX}/bin/samba"
>     if [[ $? == 0 ]]; then
>          rc_err "$0: Cannot run while AD Server Running"
>     fi
> }

I am not sure what you are looking for here. You want to make sure one cannot start samba if it's already running?
If so, rc_check() does what you want. If you meant something else, please elaborate :-)

> Secondly is it acceptable to create a common rc script to hold common subs used amongst multiple rc
> script for a port, eg samba.subr that will be used by smbd and nmbd rc scripts?

No, the only time we use a common rc script is to start all processes of a common package (like we do with samba3 already).

--
Antoine

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Ian McWilliam-2

On Thu, Jul 3rd, 2014 at 4:07 PM, Antoine Jacoutot <[hidden email]> wrote:

> On Thu, Jul 03, 2014 at 02:13:46PM +1000, Ian McWilliam wrote:
> > Hi all,
> >
> > Need some advice on the rc script infrastructure and the best way to
> detect running processes.
> >
> > is some like the following acceptable practice or are there some
> existing functions that will do the
> > equivalent.
> >
> > rc_pre() {
> >     pgrep -fq "${TRUEPREFIX}/bin/samba"
> >     if [[ $? == 0 ]]; then
> >          rc_err "$0: Cannot run while AD Server Running"
> >     fi
> > }
>
> I am not sure what you are looking for here. You want to make sure one
> cannot start samba if it's already running?
> If so, rc_check() does what you want. If you meant something else, please
> elaborate :-)
>

OK. Samba4 contains the /usr/local/bin/samba which is the full blown Active Directory Server.
The RC script for that (when I write it) will need checks to make sure that smbd / nmbd / winbindd are
not running as those daemons are not used in an ADS setup.

The above example is to check when starting the old file / print / winbind servers that the ADS server
is not running incase you accentually started any of them while running an ADS setup.

For those people just wanting smb file / print services or the old NT domain setup, you can still use
smbd / nmbd / winbind.

Hope that describes the scenarios that the samba4 stuff will give us.


> > Secondly is it acceptable to create a common rc script to hold common
> subs used amongst multiple rc
> > script for a port, eg samba.subr that will be used by smbd and nmbd rc
> scripts?
>
> No, the only time we use a common rc script is to start all processes of a
> common package (like we do with samba3 already).
>

OK, in that case, common functions will be duplicated 3 times in each of the smbd, nmbd, winbindd rc
scripts.



--
Ian McWilliam

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Antoine Jacoutot-7
> OK. Samba4 contains the /usr/local/bin/samba which is the full blown Active Directory Server.
> The RC script for that (when I write it) will need checks to make sure that smbd / nmbd / winbindd are
> not running as those daemons are not used in an ADS setup.
>
> The above example is to check when starting the old file / print / winbind servers that the ADS server
> is not running incase you accentually started any of them while running an ADS setup.
>
> For those people just wanting smb file / print services or the old NT domain setup, you can still use
> smbd / nmbd / winbind.
>
> Hope that describes the scenarios that the samba4 stuff will give us.

It does indeed.
Ok then what you came up with is ok. At least, rc_pre() is the correct function to do that kind of checks.
But you may want to use '/etc/rc.d/smbd check' ... instead.

> > > Secondly is it acceptable to create a common rc script to hold common
> > subs used amongst multiple rc
> > > script for a port, eg samba.subr that will be used by smbd and nmbd rc
> > scripts?
> >
> > No, the only time we use a common rc script is to start all processes of a
> > common package (like we do with samba3 already).
> >
>
> OK, in that case, common functions will be duplicated 3 times in each of the smbd, nmbd, winbindd rc
> scripts.

What functions exactly?
Sorry if I sound dumb but you did not provide much details and samba3 rc scripts don't seem to share any function.

--
Antoine

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Stuart Henderson-6
In reply to this post by Ian McWilliam-2
On 2014/07/03 16:23, Ian McWilliam wrote:
> OK, in that case, common functions will be duplicated 3 times in each
> of the smbd, nmbd, winbindd rc scripts.

rc scripts shouldn't be complicated/long enough that the duplication
is a problem :)

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Craig Skinner-3
In reply to this post by Ian McWilliam-2
On 2014-07-03 Thu 16:23 PM |, Ian McWilliam wrote:
>
> OK. Samba4 contains the /usr/local/bin/samba which is the full blown Active Directory Server.
> The RC script for that (when I write it) will need checks to make sure that smbd / nmbd / winbindd are
> not running as those daemons are not used in an ADS setup.

They can also be started from /etc/inetd.conf

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Craig Skinner-3
In reply to this post by Ian McWilliam-2
On 2014-07-03 Thu 14:13 PM |, Ian McWilliam wrote:
>
> Secondly is it acceptable to create a common rc script to hold common subs used amongst multiple rc
> script for a port, eg samba.subr that will be used by smbd and nmbd rc scripts?


. /usr/local/libexec/samba-control ?

Reply | Threaded
Open this post in threaded view
|

Re: rc scripts

Ian McWilliam-2
In reply to this post by Craig Skinner-3
On 3/07/2014 8:29 PM, Craig R. Skinner wrote:
> On 2014-07-03 Thu 16:23 PM |, Ian McWilliam wrote:
>> OK. Samba4 contains the /usr/local/bin/samba which is the full blown Active Directory Server.
>> The RC script for that (when I write it) will need checks to make sure that smbd / nmbd / winbindd are
>> not running as those daemons are not used in an ADS setup.
> They can also be started from /etc/inetd.conf
>

Sure. If you want to run them that way, your on your own. I wouldn't
recommend that unless your a masochist........

Ian McWilliam