7 Replies Latest reply on Jan 26, 2011 10:40 AM by peterj

    Wie schreib man script zum /etc/init.d/myJboss start

    thomas2008ch

      Es ist bei uns ein Jboss (auf LINUX) installiert. Um den Jboss zu starten bzw. zu stoppen, mach man folgendes:

       

      zum Starten: /etc/init.d/myJboss.sh start

      zum Stoppen: /etc/init.d/myJboss.sh stop

       

      Da normalerweise nicht als 'root' sondern als Normal-User den Jboss zu starten/stoppen, wird nach dem Passwort gefragt. Man findet das ist mehr oder weniger vervig. Am besten schrieb man ein Script, um das zu vereinfachen, irgendwie wie:

      jboss start

      oder

      jboss stop

       

      Man braucht nicht mehr das Passwort einzugeben. Man braucht auch nicht so vilee Chraters zu tippen.

       

      Hier 'jboss' ist das Script.

       

      Hat man einen Idee?

       

      Gruß

       

       

      Thomas

        • 1. Wie schreib man script zum /etc/init.d/myJboss start
          wdfink

          If you want to start jboss as normal user and not as root you can run <JBOSS_HOME>/bin/run.sh -c <config> -b <bind address>.

          If this is too much or you might ensure that the jboss is started with exact the parameter you want feel free to write a script that use run.sh to start.

          The script might located in /usr/local/bin (or other global path).

          Also you might set the system bit to start as root or a special user, but you should check that you open no security leak.

           

          We start JBoss in background and store the PID to ensure that we stop exact this instance, this can be done with kill <JVM PID> from the script.

          • 2. Re: Wie schreib man script zum /etc/init.d/myJboss start
            peterj

            Since you have myJBoss.sh (actually, it should just be named /etc/init.d/myJBoss, and I will assume this name in the rest of my post), why not set it up to autostart on boot?

             

            Also, which distro of Linux? On Ubuntu you can do this:

             

            sudo service myJBoss start

             

            Though I guess that is still a lot of typing. But a script named 'jboss' that contains this should work:

             

             

            #!/bin/sh

            sudo service myJBoss $*

            • 3. Re: Wie schreib man script zum /etc/init.d/myJboss start
              thomas2008ch

              1.

              We have sure set it up to autostart on boot by adding this to chkconfig list and turn it on. But very often we have to stop, start the Jboss by testing or sonmething else.

               

              2.

              In the fact the file name is myJboss, not myJboss.sh. I added ".sh" to let one know this is a script. :-)

               

              3.

              We use the LINUX LHEL 5. What should I do?

               

              My last post is written in German, could you understand it?

              • 4. Re: Wie schreib man script zum /etc/init.d/myJboss start
                peterj

                1. OK, I understand.

                 

                2. Accuracy is important! Especially if you do not want useless advice.

                 

                3. I don't have a RHEL system available. And my Fedora system is at work (I'm at home). But googling shows that the "service" command is available on Fedora and has thge same syntax - the only thing you need to do is not use sudo. This should work:

                 

                #!/bin/sh

                service myJBoss $*

                 

                I recall enough of my high school and college German to read and understand your post, but not enough to reply in like manner!

                 

                 

                #!/bin/sh

                sudo service myJBoss $*

                • 5. Re: Wie schreib man script zum /etc/init.d/myJboss start
                  thomas2008ch

                  Hi,

                   

                  Thanks for your answer. But maybe it's not what I want. :-/

                   

                   

                  What I want is: I don't want to type "/ect/ini.d/myJboss start" and enter the password to start the Jboss from my home. I want simply type "jboss start".

                  • 6. Re: Wie schreib man script zum /etc/init.d/myJboss start
                    nickarls

                    pipe in the root password into sudo. Needless to say, having your root password lying around in batch files is not a good idea. I said it anyway.

                    • 7. Re: Wie schreib man script zum /etc/init.d/myJboss start
                      peterj

                      I agree with Nicklas - putting your password into a script file is a very bad idea. The most you can do is a simple script that runs "/etc/init.d/Jboss $*", but you will still have to enter the password manually.

                       

                      And by the way, which password? Both Nicklas and I made some assumptions here, and they could be wrong. Is it the /etc/init.d/Jboss script that is asking for the password? Or are you first doing su and you need to enter the root password? Or are you running sudo ("sudo /etc/init.d/Jboss start") and sudo is prompting for your password? (Reread my prior post for asnwer #2!)