Loading ...
Sorry, an error occurred while loading the content.

problem with startup script on SlugOS BE 4.8

Expand Messages
  • prupertplum
    Hi again Simple one this time. I have created a simple startup script to load snort on start-up, but it never gets executed for some reason. It is simply:
    Message 1 of 11 , Dec 5, 2008
    • 0 Attachment
      Hi again

      Simple one this time. I have created a simple startup script to load
      snort on start-up, but it never gets executed for some reason.

      It is simply:
      #!/bin/sh
      /opt/bin/snort -c /opt/etc/snort.conf -i eth0


      Its an executable script in /etc/init.d and I have created a symlink
      to it at /etc/rc3.d/s99snort and it has the exact same permissions as
      all the other files in both init.d and rc3.d.

      But it never loads - well, snort is never shown as running in top. The
      script works fine if I run it from the command line. So I am a little
      bit stumped as to why it doesn't load at boot.

      The only issue I see is that all the other symlinks in rc3.d are
      replicated in all the other rcX.ds. So do I need to create symlinks in
      all the rcX.ds for my script to work? According to the wiki, I need
      only create one symlink in rc3.d since my runlevel is 3....

      Any views much appreciated...
    • James Fidell
      ... Could be one of any number of reasons. First it s probably worth checking that the script does actually get run at boot time, perhaps by adding something
      Message 2 of 11 , Dec 5, 2008
      • 0 Attachment
        prupertplum wrote:
        > Hi again
        >
        > Simple one this time. I have created a simple startup script to load
        > snort on start-up, but it never gets executed for some reason.
        >
        > It is simply:
        > #!/bin/sh
        > /opt/bin/snort -c /opt/etc/snort.conf -i eth0
        >
        >
        > Its an executable script in /etc/init.d and I have created a symlink
        > to it at /etc/rc3.d/s99snort and it has the exact same permissions as
        > all the other files in both init.d and rc3.d.
        >
        > But it never loads - well, snort is never shown as running in top. The
        > script works fine if I run it from the command line. So I am a little
        > bit stumped as to why it doesn't load at boot.

        Could be one of any number of reasons.

        First it's probably worth checking that the script does actually get run
        at boot time, perhaps by adding something like:

        date > /var/tmp/snort

        as the first line of the script to see if /var/tmp/snort does get
        created at boot time. If it does then change the second line to read:

        /opt/bin/snort -c /opt/etc/snort.conf -i eth0 2>&1 >/var/tmp/snort.log

        and see if that provides anything useful by way of output.

        Or you could add:

        if [ $? -eq 0 ]; then
        echo "snort ok" > /var/tmp/snort.log
        else
        echo "snort failed" > /var/tmp/snort.log
        fi

        at the end of the script.

        James
      • shinji2570
        ... I don t personally run SlugOS but I would actually adjust the script as follows. #!/bin/sh echo snort run /var/tmp/snort.log /opt/bin/snort -c
        Message 3 of 11 , Dec 6, 2008
        • 0 Attachment
          --- In nslu2-linux@yahoogroups.com, James Fidell <james@...> wrote:
          >
          > prupertplum wrote:
          > > Hi again
          > >
          > > Simple one this time. I have created a simple startup script to load
          > > snort on start-up, but it never gets executed for some reason.
          > >
          > > It is simply:
          > > #!/bin/sh
          > > /opt/bin/snort -c /opt/etc/snort.conf -i eth0
          > >
          > >
          > > Its an executable script in /etc/init.d and I have created a symlink
          > > to it at /etc/rc3.d/s99snort and it has the exact same permissions as
          > > all the other files in both init.d and rc3.d.
          > >
          > > But it never loads - well, snort is never shown as running in top. The
          > > script works fine if I run it from the command line. So I am a little
          > > bit stumped as to why it doesn't load at boot.
          >
          > Could be one of any number of reasons.
          >
          > First it's probably worth checking that the script does actually get run
          > at boot time, perhaps by adding something like:
          >
          > date > /var/tmp/snort
          >
          > as the first line of the script to see if /var/tmp/snort does get
          > created at boot time. If it does then change the second line to read:
          >
          > /opt/bin/snort -c /opt/etc/snort.conf -i eth0 2>&1 >/var/tmp/snort.log
          >
          > and see if that provides anything useful by way of output.
          >
          > Or you could add:
          >
          > if [ $? -eq 0 ]; then
          > echo "snort ok" > /var/tmp/snort.log
          > else
          > echo "snort failed" > /var/tmp/snort.log
          > fi
          >
          > at the end of the script.
          >
          > James
          >

          I don't personally run SlugOS but I would actually adjust the script
          as follows.

          #!/bin/sh
          echo "snort run" > /var/tmp/snort.log
          /opt/bin/snort -c /opt/etc/snort.conf -i eth0 >> /var/tmp/snort.log 2>&1
          export exit=$?
          if [ $exit -eq 0 ]; then
          echo "snort ok" >> /var/tmp/snort.log
          else
          echo "snort failed and exit with error $exit" >> /var/log/snort.log
          fi

          My example is basically a combination of the above settings with my
          own little addition. For issue tracking purposes the script it
          produces several echo statements and in the case of failure it is able
          to echo out the error code for snort. If you don't export the exit
          code into another variable you will lose it after running the
          condition check. Trust me I've tested that one before. Anyways once
          you have the exit code then maybe you can research it and see what it
          means. The logged output of the command may also provide some hints
          as to what is going on. The initial first line (right after /bin/sh)
          will tell you if the script is being executed.

          P.S. - The redirect entry for the actual command would of resulted in
          only stdout being sent to the file. I fixed it so that both stdout
          and stderr would go to the file.
        • prupertplum
          Cool, thanks for the suggestions, I will try out what you said and report back. I am pretty sure the script isn t being run at all, since I tried adding an
          Message 4 of 11 , Dec 6, 2008
          • 0 Attachment
            Cool, thanks for the suggestions, I will try out what you said and
            report back. I am pretty sure the script isn't being run at all, since
            I tried adding an echo script started today > /home/test.txt to the
            script, but the file wasn't screated :(
            --- In nslu2-linux@yahoogroups.com, James Fidell <james@...> wrote:
            >
            > prupertplum wrote:
            > > Hi again
            > >
            > > Simple one this time<snip>
            > at the end of the script.
            >
            > James
            >
          • prupertplum
            Thanks for this update, I will test this one out as well. Hopefully, when my Linux Bible arrives for Xmas, I will be able to work out what all the commandes
            Message 5 of 11 , Dec 6, 2008
            • 0 Attachment
              Thanks for this update, I will test this one out as well. Hopefully,
              when my Linux Bible arrives for Xmas, I will be able to work out what
              all the commandes were that you used and how they work ;)

              Will update with results.

              Right, I tried both scripts, still no luck and no logs being written
              where they should. So it seems the script isn't being run at boot,
              there is no mention of any scripts failing in dmesg.

              I am at a bit of a loss here - I suppose I could replicate the symlink
              across rcX.d but that sounds kinda crazy to me.

              One thing that aint clear from the wiki is which is the best firmware
              to choose currently (i.e. 2008) such that all feeds and packages are
              up-to-date and the OS is still being actively developed. It seems
              SlugOS or Debian is the way to go if you want a modern kernal to run
              on an external drive....just wanted to check I wasn't shooting myself
              in the foot by using SlugOS.

              --- In nslu2-linux@yahoogroups.com, "shinji2570" <shinji@...> wrote:
              >
              > --- In nslu2-linux@yahoogroups.com, James Fidell <james@> wrote:
              > >
              > > <snip>would go to the file.
              >
            • reuter.rudolf
              ... Hello, I have a similar problem. My start script for a Python program is in /etc/init.d/moin.sh. If I start it from the command line it works. The script
              Message 6 of 11 , Jan 8, 2009
              • 0 Attachment
                --- In nslu2-linux@yahoogroups.com, "prupertplum" <r.plumridge@...> wrote:
                >
                > Hi again
                >
                > Simple one this time. I have created a simple startup script to load
                > snort on start-up, but it never gets executed for some reason.
                >
                > It is simply:
                > #!/bin/sh
                > /opt/bin/snort -c /opt/etc/snort.conf -i eth0
                >
                >
                > Its an executable script in /etc/init.d and I have created a symlink
                > to it at /etc/rc3.d/s99snort and it has the exact same permissions as
                > all the other files in both init.d and rc3.d.
                >
                > But it never loads - well, snort is never shown as running in top. The
                > script works fine if I run it from the command line. So I am a little
                > bit stumped as to why it doesn't load at boot.
                >
                > The only issue I see is that all the other symlinks in rc3.d are
                > replicated in all the other rcX.ds. So do I need to create symlinks in
                > all the rcX.ds for my script to work? According to the wiki, I need
                > only create one symlink in rc3.d since my runlevel is 3....
                >
                > Any views much appreciated...
                >
                Hello,

                I have a similar problem. My start script for a Python program is in
                /etc/init.d/moin.sh. If I start it from the command line it works.
                The script actually starts as I can see from a logging:
                echo "test" | logger
                an read with logread as root.
                I figured out, that the path /opt/bin is not there at boot time, why?

                Help would be very much appeciated, Rudy
              • jl.050877@gmail.com
                ... As for why /opt/bin is missing on boot-up, if it is, I don t know specifically in this case but, in general, it is the Unix philosophy to restrict the
                Message 7 of 11 , Jan 8, 2009
                • 0 Attachment
                  On Thu, Jan 08, 2009 at 05:37:18PM -0000, reuter.rudolf wrote:
                  > I have a similar problem. My start script for a Python program is in
                  > /etc/init.d/moin.sh. If I start it from the command line it works.
                  > The script actually starts as I can see from a logging:
                  > echo "test" | logger
                  > an read with logread as root.
                  > I figured out, that the path /opt/bin is not there at boot time, why?

                  As for why /opt/bin is missing on boot-up, if it is, I don't
                  know specifically in this case but, in general, it is the Unix
                  philosophy to restrict the path, as well as the rest of the
                  environment, so as to make it harder for virus/worms/whatever to do
                  their tricks to gain control.

                  If your analysis is correct, then the solution, if you haven't
                  solved it already, is to set the path in the script moin.sh. After
                  the initial comments but before any executable lines, add a line
                  like:

                  export PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/opt/bin

                  except that you should replace the path I used above with whatever
                  is the correct path is on your system for the user who runs moin.sh
                  (probably root). From the command prompt as that user, type
                  "echo $PATH" and copy the output into the above.

                  John
                • reuter.rudolf
                  ... Hello John, Thank you for the good explanation of the background. I have implemented your hint, but it did not work unfortunately. Yes, I agree it has
                  Message 8 of 11 , Jan 9, 2009
                  • 0 Attachment
                    --- In nslu2-linux@yahoogroups.com, jl.050877@... wrote:
                    >
                    > On Thu, Jan 08, 2009 at 05:37:18PM -0000, reuter.rudolf wrote:
                    > > I have a similar problem. My start script for a Python program is in
                    > > /etc/init.d/moin.sh. If I start it from the command line it works.
                    > > The script actually starts as I can see from a logging:
                    > > echo "test" | logger
                    > > an read with logread as root.
                    > > I figured out, that the path /opt/bin is not there at boot time, why?
                    >
                    > As for why /opt/bin is missing on boot-up, if it is, I don't
                    > know specifically in this case but, in general, it is the Unix
                    > philosophy to restrict the path, as well as the rest of the
                    > environment, so as to make it harder for virus/worms/whatever to do
                    > their tricks to gain control.
                    >
                    > If your analysis is correct, then the solution, if you haven't
                    > solved it already, is to set the path in the script moin.sh. After
                    > the initial comments but before any executable lines, add a line
                    > like:
                    >
                    > export PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/opt/bin
                    >
                    > except that you should replace the path I used above with whatever
                    > is the correct path is on your system for the user who runs moin.sh
                    > (probably root). From the command prompt as that user, type
                    > "echo $PATH" and copy the output into the above.
                    >
                    > John
                    >
                    Hello John,

                    Thank you for the good explanation of the background. I have
                    implemented your hint, but it did not work unfortunately. Yes, I agree
                    it has something to do with the startup routine. It is strange that in
                    my script "moin.sh":
                    mkdir -m 755 "/var/volatile/www" 2>&1 | logger
                    does work (the RAM-disk was created), but not:
                    echo $PATH | logger

                    At the moment I am trying to figure out in a shell script if
                    "/opt/bin" is alread in $PATH. But as it looks like with the new
                    "export ..." command, it will not be the cause of the trouble. So I am
                    digging deeper into the init process of linux.

                    Greetings, Rudi
                  • reuter.rudolf
                    ... why? ... Hello John, Thank you for the good explanation of the background. At the first try of your hint I fooled myself by mixing up a link with an old
                    Message 9 of 11 , Jan 9, 2009
                    • 0 Attachment
                      --- In nslu2-linux@yahoogroups.com, "reuter.rudolf" <reuterru@...> wrote:
                      >
                      > --- In nslu2-linux@yahoogroups.com, jl.050877@ wrote:
                      > >
                      > > On Thu, Jan 08, 2009 at 05:37:18PM -0000, reuter.rudolf wrote:
                      > > I have a similar problem. My start script for a Python program is in
                      > > /etc/init.d/moin.sh. If I start it from the command line it works.
                      > > The script actually starts as I can see from a logging:
                      > > echo "test" | logger
                      > > an read with logread as root.
                      > > I figured out, that the path /opt/bin is not there at boot time,
                      why?
                      >
                      > As for why /opt/bin is missing on boot-up, if it is, I don't
                      > know specifically in this case but, in general, it is the Unix
                      > philosophy to restrict the path, as well as the rest of the
                      > environment, so as to make it harder for virus/worms/whatever to do
                      > their tricks to gain control.
                      >
                      > If your analysis is correct, then the solution, if you haven't
                      > solved it already, is to set the path in the script moin.sh. After
                      > the initial comments but before any executable lines, add a line
                      > like:
                      >
                      > export PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/opt/bin
                      >
                      > except that you should replace the path I used above with whatever
                      > is the correct path is on your system for the user who runs moin.sh
                      > (probably root). From the command prompt as that user, type
                      > "echo $PATH" and copy the output into the above.
                      >
                      > John

                      Hello John,

                      Thank you for the good explanation of the background. At the first try
                      of your hint I fooled myself by mixing up a link with an old shell
                      file in /etc/rc3.d. Now I found my error, and voila you are perfectly
                      right with the "export PATH ..." statement, that solved my problem.

                      Thank you very much for your great help.

                      With best regards, Rudy
                    • Neil Ronketti
                      Hello The List, I have a very simple question, and I rather suspect I m missing something obvious - so apologies if this has been asked before. I m
                      Message 10 of 11 , Jan 9, 2009
                      • 0 Attachment
                        </lurk>

                        Hello The List,

                        I have a very simple question, and I rather suspect I'm missing
                        something obvious - so apologies if this has been asked before.

                        I'm trying to edit one of the wiki pages at
                        http://www.nslu2-linux.org/wiki/HowTo/AddUSBOneWireAdapter to give an
                        example of a init.d script that can be used to automagically kick
                        digitemp into life when the slug is booted. When I try to edit the page,
                        I'm prompted for a password, which I don't have.

                        So, I go off to look at http://www.nslu2-linux.org/wiki/PmWiki/PmWiki
                        and the advice there states: "Getting edit access: If you spot a mistake
                        or see an opportunity for improvement on a password-protected page, you
                        need to get a password in order to edit the page. Todo: document the
                        process for getting such a password."

                        Can anyone enlighten me as to how I can add this info? I promise to also
                        update the wiki page on how to request such a password :)

                        First post. Please be gentle.

                        Many thanks,
                        nr.
                      • Rod Whitby
                        The password is on the bottom of the front page of the wiki. -- Rod ... From: Neil Ronketti Date: Saturday, Jan 10, 2009 8:18 am Subject:
                        Message 11 of 11 , Jan 9, 2009
                        • 0 Attachment
                          The password is on the bottom of the front page of the wiki.
                          -- Rod

                          -----Original Message-----
                          From: Neil Ronketti <neil@...>
                          Date: Saturday, Jan 10, 2009 8:18 am
                          Subject: [nslu2-linux] nslu2-linux.org wiki
                          To: nslu2-linux@yahoogroups.comReply-To: nslu2-linux@yahoogroups.com

                          </lurk>
                          >
                          >Hello The List,
                          >
                          >I have a very simple question, and I rather suspect I'm missing
                          >something obvious - so apologies if this has been asked before.
                          >
                          >I'm trying to edit one of the wiki pages at
                          >http://www.nslu2-linux.org/wiki/HowTo/AddUSBOneWireAdapter to give an
                          >example of a init.d script that can be used to automagically kick
                          >digitemp into life when the slug is booted. When I try to edit the page,
                          >I'm prompted for a password, which I don't have.
                          >
                          >So, I go off to look at http://www.nslu2-linux.org/wiki/PmWiki/PmWiki
                          >and the advice there states: "Getting edit access: If you spot a mistake
                          >or see an opportunity for improvement on a password-protected page, you
                          >need to get a password in order to edit the page. Todo: document the
                          >process for getting such a password."
                          >
                          >Can anyone enlighten me as to how I can add this info? I promise to also
                          >update the wiki page on how to request such a password :)
                          >
                          >First post. Please be gentle.
                          >
                          >Many thanks,
                          >nr.
                          >
                          >------------------------------------
                          >
                          >Yahoo! Groups Links
                          >
                          >
                          >
                          >
                        Your message has been successfully submitted and would be delivered to recipients shortly.