Why won't this init.d script work at startup?? - Suse

This is a discussion on Why won't this init.d script work at startup?? - Suse ; I know the following /etc/init.d/blueduck script works because I've used it on the command line tons of times. It has 555 perms and the / etc/init.d/rc5.d links exist. It *never* works at startup. And, there are no error messages in ...

+ Reply to Thread
Results 1 to 17 of 17

Thread: Why won't this init.d script work at startup??

  1. Why won't this init.d script work at startup??

    I know the following /etc/init.d/blueduck script works because I've
    used it on the command line tons of times. It has 555 perms and the /
    etc/init.d/rc5.d links exist. It *never* works at startup. And,
    there are no error messages in /var/log/messages with "blueduck" in
    the line.

    What am I doing wrong? Python is ok here right? Also, I run the app
    as a non-root user. That is ok too right? (Remember this all work on
    command line with sudo all the time.)




    #!/usr/bin/env python
    #
    ### BEGIN INIT INFO
    # Provides: blueduck
    # Required-Start: $network $syslog
    # Required-Stop: $network $syslog
    # Default-Start: 3 5
    # Default-Stop: 0 1 2 6
    # Description: Blueduck OSLG scanning web application
    ### END INIT INFO

    import sys
    import os

    def start():
    os.system("su cseberin -c '/usr/local/blueduck/run.blueduck'")

    def stop():
    os.system('kill `ps -ef | grep start-blueduck | cut -b 10-14`
    \
    1> /dev/null 2> /dev/null ; sleep 4')

    if sys.argv[1] == "start":
    start()

    if sys.argv[1] == "stop":
    stop()

    if sys.argv[1] == "restart":
    stop()
    start()

  2. Re: Why won't this init.d script work at startup??

    seberino@spawar.navy.mil wrote:
    > I know the following /etc/init.d/blueduck script works because I've
    > used it on the command line tons of times. It has 555 perms and the /
    > etc/init.d/rc5.d links exist. It *never* works at startup. And,
    > there are no error messages in /var/log/messages with "blueduck" in
    > the line.
    >
    > What am I doing wrong? Python is ok here right? Also, I run the app
    > as a non-root user. That is ok too right? (Remember this all work on
    > command line with sudo all the time.)


    What links do you have in rc5.d?

    > def start():
    > os.system("su cseberin -c '/usr/local/blueduck/run.blueduck'")
    >
    > def stop():
    > os.system('kill `ps -ef | grep start-blueduck | cut -b 10-14`
    > \


    I would make it much. First I would see that I can run it as root. Then
    I would just symlink run.blueduck e.g.
    ln -s /usr/local/blueduck/run.blueduck rc5.d/S10blueduck

    Or I would add it to some boot.local(?) file in /etc/init.d, which makes
    it even easier.

    Obviously I have no idea what the script does, so take all with a huge
    grain of salt.

    houghi
    --
    Let's not be too tough on our own ignorance. It's the thing that makes
    America great. If America weren't incomparably ignorant, how could we
    have tolerated the last eight years? -- Frank Zappa, in 1988

  3. Re: Why won't this init.d script work at startup??

    Did you use chkconfig -a to add it?

    What is the output of chkconfig blueduck?

    It's also nice (but not necessary) to add a symlink
    /usr/sbin/rcblueduck -> /etc/init.d/blueduck.

  4. Re: Why won't this init.d script work at startup??

    On May 21, 1:29 am, "seber...@spawar.navy.mil"
    wrote:
    > I know the following /etc/init.d/blueduck script works because I've
    > used it on the command line tons of times. It has 555 perms and the /
    > etc/init.d/rc5.d links exist. It *never* works at startup. And,
    > there are no error messages in /var/log/messages with "blueduck" in
    > the line.
    >
    > What am I doing wrong? Python is ok here right? Also, I run the app
    > as a non-root user. That is ok too right? (Remember this all work on
    > command line with sudo all the time.)
    >


    Its OK to run the app as a non-root - but not this startup script.

    > #!/usr/bin/env python


    Why do you use the stripped env to run it in?
    Have you tried
    #!/usr/bin/python

    (or wherever your python is)

    C.

  5. Re: Why won't this init.d script work at startup??

    On Tue, 20 May 2008 17:29:21 -0700, seberino@spawar.navy.mil wrote:

    > I know the following /etc/init.d/blueduck script works because I've used
    > it on the command line tons of times. It has 555 perms and the /
    > etc/init.d/rc5.d links exist. It *never* works at startup. And, there
    > are no error messages in /var/log/messages with "blueduck" in the line.
    >
    > What am I doing wrong? Python is ok here right? Also, I run the app as
    > a non-root user. That is ok too right? (Remember this all work on
    > command line with sudo all the time.)
    >
    >




    What kind of application is it? I can't see anything called blueduck on
    the 'interweb'. If it is a GUI then it will run when called by a user
    but won't run from a start script. You can't easily run a GUI
    application outside of an interactive login session.

    JohnK

  6. Re: Why won't this init.d script work at startup??

    On May 21, 12:14 am, houghi wrote:
    > seber...@spawar.navy.mil wrote:
    > > I know the following /etc/init.d/blueduck script works because I've
    > > used it on the command line tons of times. It has 555 perms and the /
    > > etc/init.d/rc5.d links exist. It *never* works at startup. And,
    > > there are no error messages in /var/log/messages with "blueduck" in
    > > the line.

    >
    > > What am I doing wrong? Python is ok here right? Also, I run the app
    > > as a non-root user. That is ok too right? (Remember this all work on
    > > command line with sudo all the time.)

    >
    > What links do you have in rc5.d?


    /etc/init.d/rc5.d/K11blueduck -> ../blueduck
    /etc/init.d/rc5.d/S11blueduck -> ../blueduck


    > > def start():
    > > os.system("su cseberin -c '/usr/local/blueduck/run.blueduck'")

    >
    > > def stop():
    > > os.system('kill `ps -ef | grep start-blueduck | cut -b 10-14`
    > > \

    >
    > I would make it much. First I would see that I can run it as root. Then
    > I would just symlink run.blueduck e.g.
    > ln -s /usr/local/blueduck/run.blueduck rc5.d/S10blueduck


    My /etc/init.d/blueduck is just a wrapper that changes the uid and
    runs
    /usr/local/blueduck/run.blueduck as shown above.


    > Or I would add it to some boot.local(?) file in /etc/init.d, which makes
    > it even easier.
    >
    > Obviously I have no idea what the script does, so take all with a huge
    > grain of salt.


    Just starts a web app. What is a boot.local file?

  7. Re: Why won't this init.d script work at startup??

    On May 21, 4:57 am, Gary Gapinski wrote:
    > Did you use chkconfig -a to add it?
    >
    > What is the output of chkconfig blueduck?


    % chkconfig blueduck
    blueduck 5



    > It's also nice (but not necessary) to add a symlink
    > /usr/sbin/rcblueduck -> /etc/init.d/blueduck.


    I added that.

  8. Re: Why won't this init.d script work at startup??

    On May 21, 5:49 am, "C. (http://symcbean.blogspot.com/)"
    wrote:

    > Its OK to run the app as a non-root - but not this startup script.


    Yes thanks. My startup script is run by root and it runs my web app
    as a non-root user.

    > > #!/usr/bin/env python

    >
    > Why do you use the stripped env to run it in?
    > Have you tried
    > #!/usr/bin/python


    I think env is used to find the path to one's python automagically.
    Supposedly this makes the script more portable across different
    machines with different paths to the Python interpreter. On a fully
    booted machine "sudo /etc/init.d/blueduck restart" works.
    Do you still think since that works I should remove the env?

  9. Re: Why won't this init.d script work at startup??

    On May 21, 12:11 pm, JohnK wrote:

    > What kind of application is it? I can't see anything called blueduck on
    > the 'interweb'. If it is a GUI then it will run when called by a user
    > but won't run from a start script. You can't easily run a GUI
    > application outside of an interactive login session.


    It is a web app based on the TurboGears Python web framework I created
    on my own.

    cs

  10. Re: Why won't this init.d script work at startup??

    seberino@spawar.navy.mil wrote:
    >> Obviously I have no idea what the script does, so take all with a huge
    >> grain of salt.

    >
    > Just starts a web app. What is a boot.local file?


    I still have no idea what it does. Or more importandt what it relies on.
    As somebody else already hinted out, it could be that it needs a GUI. It
    also could be that it needs other things to be loaded first. Things that
    won't work when you

    boot.local is /etc/init.d/boot.local. From that file:

    # script with local commands to be executed from init on system startup
    #
    # Here you should add things, that should happen directly after booting
    # before we're going to the first run level.

    e.g. I have some modprobes and sensors in there.

    houghi
    --
    This was written under the influence of the following:
    | Artist : Frank Zappa
    | Song : Nap Time
    | Album : Everything Is Healing Nicely

  11. Re: Why won't this init.d script work at startup??

    On May 21, 2:24 pm, houghi wrote:
    > seber...@spawar.navy.mil wrote:


    > I still have no idea what it does. Or more importandt what it relies on.
    > As somebody else already hinted out, it could be that it needs a GUI. It
    > also could be that it needs other things to be loaded first. Things that
    > won't work when you


    This Python TurboGears based web app relies on networking. Rather
    than determining everything it relies on, I noticed that you can add
    $ALL to the dependencies.
    (It is a "UnitedLinux extension".) That should take care of any
    worries about order of starting services.

  12. Re: Why won't this init.d script work at startup??

    seberino@spawar.navy.mil wrote:
    > On May 21, 12:11 pm, JohnK wrote:
    >
    >> What kind of application is it? I can't see anything called blueduck on
    >> the 'interweb'. If it is a GUI then it will run when called by a user
    >> but won't run from a start script. You can't easily run a GUI
    >> application outside of an interactive login session.

    >
    > It is a web app based on the TurboGears Python web framework I created
    > on my own.
    >
    > cs


    You sure a .kde autostart entry (or gnome equivalent) wouldn't be
    sufficient? Then it will run when you login to X.

    I only say this because I see you are wanting it to run in runlevel 5.
    So I assume it needs X and networking up..? Is it serving web apps, or
    is it something that opens up a web browser?

  13. Re: Why won't this init.d script work at startup??

    On May 21, 6:08 pm, larry wrote:

    > You sure a .kde autostart entry (or gnome equivalent) wouldn't be
    > sufficient? Then it will run when you login to X.
    >
    > I only say this because I see you are wanting it to run in runlevel 5.
    > So I assume it needs X and networking up..? Is it serving web apps, or
    > is it something that opens up a web browser?


    It is just a web server based app. I don't need X up. I only set it
    for level 3 and 5 because I copied that from the skeleton.

    I simplified the boiler plate and it still won't work w/ $ALL...

    #!/usr/bin/env python
    #
    ### BEGIN INIT INFO
    # Provides: blueduck
    # Required-Start: $ALL
    # Default-Start: 3 5
    # Default-Stop: 0 1 2 6
    # Description: Blueduck OSLG scanning web application
    # Short-Description: scanning tool
    ### END INIT INFO



  14. Re: Why won't this init.d script work at startup??

    seberino@spawar.navy.mil wrote:
    > I simplified the boiler plate and it still won't work w/ $ALL...
    >
    > #!/usr/bin/env python
    > #
    > ### BEGIN INIT INFO
    > # Provides: blueduck
    > # Required-Start: $ALL
    > # Default-Start: 3 5
    > # Default-Stop: 0 1 2 6
    > # Description: Blueduck OSLG scanning web application
    > # Short-Description: scanning tool
    > ### END INIT INFO


    As everything that begins with a # is a comment, you actualy have done
    completely nothing. Those are just comments and I doubt that they
    otherwise would do anything.

    I have no idea how python works, but I am curious as to what $ALL has as
    content. My guess is it is empty.

    houghi
    --
    All opinions are not equal. Some are a very great deal more robust,
    sophisticated and well supported in logic and argument than others.

  15. Re: Why won't this init.d script work at startup??

    On 2008-05-22 09:10, houghi wrote:
    > seberino@spawar.navy.mil wrote:
    >> I simplified the boiler plate and it still won't work w/ $ALL...
    >>
    >> #!/usr/bin/env python
    >> #
    >> ### BEGIN INIT INFO
    >> # Provides: blueduck
    >> # Required-Start: $ALL
    >> # Default-Start: 3 5
    >> # Default-Stop: 0 1 2 6
    >> # Description: Blueduck OSLG scanning web application
    >> # Short-Description: scanning tool
    >> ### END INIT INFO

    >
    > As everything that begins with a # is a comment, you actualy have done
    > completely nothing. Those are just comments and I doubt that they
    > otherwise would do anything.
    >
    > I have no idea how python works, but I am curious as to what $ALL has as
    > content. My guess is it is empty.
    >
    > houghi


    The key is used by chkconfig to assign the right name on the rc links,
    eg. the start and stop order.

    $ALL will probably create S99* links

    /bb

  16. Re: Why won't this init.d script work at startup??

    seberino@spawar.navy.mil wrote:
    > On May 21, 4:57 am, Gary Gapinski wrote:
    >> Did you use chkconfig -a to add it?


    And you did not answer.

    >>
    >> What is the output of chkconfig blueduck?

    >
    > % chkconfig blueduck
    > blueduck 5


    Odd.

    What is the output of chkconfig -l blueduck?


    In any case, I slightly altered the script to

    #!/usr/bin/env python
    #
    ### BEGIN INIT INFO
    # Provides: blueduck
    # Required-Start: $network $syslog
    # Required-Stop: $network $syslog
    # Default-Start: 3 5
    # Default-Stop: 0 1 2 6
    # Description: Blueduck OSLG scanning web application
    ### END INIT INFO

    import sys
    import os

    def start():
    os.system("logger 'starting blueduck'")

    def stop():
    os.system("logger 'stopping blueduck'")

    os.system("logger 'blueduck invoked'")

    if sys.argv[1] == "start":
    start()

    if sys.argv[1] == "stop":
    stop()

    if sys.argv[1] == "restart":
    stop()
    start()

    and then placed it in /etc/init.d.

    Then ran
    chipotle:~ # chkconfig -a blueduck
    blueduck 0ff 1ff 2ff 3n 4ff 5n 6ff
    chipotle:~ # chkconfig -l blueduck
    blueduck 0ff 1ff 2ff 3n 4ff 5n 6ff
    chipotle:~ # find /etc -name '*blueduck*' -print
    /etc/init.d/rc5.d/S07blueduck
    /etc/init.d/rc5.d/K15blueduck
    /etc/init.d/rc3.d/S07blueduck
    /etc/init.d/rc3.d/K15blueduck
    /etc/init.d/blueduck
    chipotle:~ #

    Then rebooted the system to runlevel 3, and found the expected log
    messages (invoked, starting) immediately after the syslog-ng starting
    message. When the system was sent to runlevel 6, the expected messages
    (invoked, stopping) were observed.

    So, I suspect that you did not use chkconfig -a to add the service and
    create the appropriate symlinks, or perhaps it is not returning from the
    su, or the command used to start the service is not doing so.

    Even though the script appears to work when trivialized as above, you
    would get a more pleasant-looking result if you were to duplicate a
    pre-existing service script (e.g., sshd, postfix) and adapt it for this
    service.

  17. Re: Why won't this init.d script work at startup??

    On May 22, 5:34 am, Gary Gapinski wrote:
    > seber...@spawar.navy.mil wrote:
    > > On May 21, 4:57 am, Gary Gapinski wrote:
    > >> Did you use chkconfig -a to add it?

    >
    > And you did not answer.
    >
    >
    >
    > >> What is the output of chkconfig blueduck?

    >
    > > % chkconfig blueduck
    > > blueduck 5

    >
    > Odd.
    >
    > What is the output of chkconfig -l blueduck?
    >
    > In any case, I slightly altered the script to
    >
    > #!/usr/bin/env python
    > #
    > ### BEGIN INIT INFO
    > # Provides: blueduck
    > # Required-Start: $network $syslog
    > # Required-Stop: $network $syslog
    > # Default-Start: 3 5
    > # Default-Stop: 0 1 2 6
    > # Description: Blueduck OSLG scanning web application
    > ### END INIT INFO
    >
    > import sys
    > import os
    >
    > def start():
    > os.system("logger 'starting blueduck'")
    >
    > def stop():
    > os.system("logger 'stopping blueduck'")
    >
    > os.system("logger 'blueduck invoked'")
    >
    > if sys.argv[1] == "start":
    > start()
    >
    > if sys.argv[1] == "stop":
    > stop()
    >
    > if sys.argv[1] == "restart":
    > stop()
    > start()
    >
    > and then placed it in /etc/init.d.
    >
    > Then ran
    > chipotle:~ # chkconfig -a blueduck
    > blueduck 0ff 1ff 2ff 3n 4ff 5n 6ff
    > chipotle:~ # chkconfig -l blueduck
    > blueduck 0ff 1ff 2ff 3n 4ff 5n 6ff
    > chipotle:~ # find /etc -name '*blueduck*' -print
    > /etc/init.d/rc5.d/S07blueduck
    > /etc/init.d/rc5.d/K15blueduck
    > /etc/init.d/rc3.d/S07blueduck
    > /etc/init.d/rc3.d/K15blueduck
    > /etc/init.d/blueduck
    > chipotle:~ #
    >
    > Then rebooted the system to runlevel 3, and found the expected log
    > messages (invoked, starting) immediately after the syslog-ng starting
    > message. When the system was sent to runlevel 6, the expected messages
    > (invoked, stopping) were observed.
    >
    > So, I suspect that you did not use chkconfig -a to add the service and
    > create the appropriate symlinks, or perhaps it is not returning from the
    > su, or the command used to start the service is not doing so.
    >
    > Even though the script appears to work when trivialized as above, you
    > would get a more pleasant-looking result if you were to duplicate a
    > pre-existing service script (e.g., sshd, postfix) and adapt it for this
    > service.


    Thanks for all the help. I found the problem by adding print
    statements to my init.d script. The init.d script *was* running but
    the su command to drop down to a non-root user wanted a password.
    This new machine has the su command locked down somehow such that my
    su line was being ignored. So this is a security setting problem not
    a Suse init.d script problem.

    thanks again for the help

+ Reply to Thread