Boot Scripts


Results 1 to 13 of 13

Thread: Boot Scripts

  1. #1
    Join Date
    Sep 2008
    Posts
    11

    Boot Scripts

    Okay, I FINALLY got tired of MS Winidoze, so I upgraded to Ubuntu. Now, I need to learn Linux for two reasons. I have developed PHP sites for many years, finally learned Java though and now I need to deploy a chat server. The question is, how do you get the Linux boot to read the boot scripts? I have the script done (copy and pasted from another help site) and even added the symlinks. But the system does not recognize it as a script (it's in the init.d directory as it said to do in Ubuntu). I need to know how to do this in both Ubuntu and for the Linux OS. Also, I need to know how to do it in a way that I can use a remote terminal for the website host.

  2. #2
    Join Date
    Sep 2008
    Posts
    11

    Pid?

    Okay, what is the PID and do I have to add one for the script?

  3. #3
    Join Date
    Sep 2008
    Posts
    11

    Yay Me!

    I always surprise myself. After a bit of work I figured out what I was doing wrong. Sorry to bother you. If anyone else is having the same problem I am go here: http://linuxreviews.org/man/start-stop-daemon/ for some serious help on daemon stuff. Turns out I just didn't have the right switches from the first help forum.

  4. #4
    Join Date
    Sep 1999
    Posts
    3,202
    Did you make the script executable?

    Assuming it is in /etc/init.d/myscript

    Do (as root) chmod +x /etc/init.d/myscript

  5. #5
    Join Date
    Sep 2008
    Posts
    11
    Quote Originally Posted by ph34r
    Did you make the script executable?

    Assuming it is in /etc/init.d/myscript

    Do (as root) chmod +x /etc/init.d/myscript
    Yes. Got that part, it works from the command line with sudo bash myscript but I still can't get it to autorun on a boot or reboot, so I need to look a little more. Unless someone here can help. I put symlinks in rs3, rc4, and rc5 .d's, not sure if that's exactly what I was suppose to but the info on the boot levels is still new to me (gotta get the laziness of Windoze out of my head still).
    Last edited by KittenKoder; 09-16-2008 at 11:24 AM. Reason: Forgot

  6. #6
    Join Date
    Jul 2002
    Location
    Tallahassee, FL
    Posts
    512
    If the script is called /etc/init.d/foo, run:
    Code:
    update-rc.d foo defaults
    For more info:
    http://www.debuntu.org/how-to-manage...th-update-rc.d
    Registered Linux User No. 321,742

    "At Harvard they have this policy where if you pass too many classes they ask you to leave."
    ---Richard M. Stallman

  7. #7
    Join Date
    Sep 2008
    Posts
    11
    Quote Originally Posted by paj12
    If the script is called /etc/init.d/foo, run:
    Code:
    update-rc.d foo defaults
    For more info:
    http://www.debuntu.org/how-to-manage...th-update-rc.d
    Just tried that to, it still doesn't load and run on boot up. The script in the init.d works fine otherwise, it just doesn't do anything when booting.
    Last edited by KittenKoder; 09-16-2008 at 02:00 PM.

  8. #8
    Join Date
    Sep 2008
    Posts
    11
    Updated information, think it's important.

    Other scripts do not seem to require bash in front of them, but to run the one I am trying I have to type bash in front of it, any clue as to why that is?

  9. #9
    Join Date
    Jan 2003
    Posts
    1,012
    Quote Originally Posted by KittenKoder
    Updated information, think it's important.

    Other scripts do not seem to require bash in front of them, but to run the one I am trying I have to type bash in front of it, any clue as to why that is?

    First line in your script put this;

    #!/bin/bash
    You can tuna piano, but you can't tune a fish.

    http://www.lunar-linux.org/
    It's worth the spin.

    http://www.pclinuxos.com/page.php?7
    Puts the rest to shame.

  10. #10
    Join Date
    Sep 2008
    Posts
    11
    Aaaahhh ... let me try that, everything else said:

    #!bin/sh

    Nope, that didn't help. It's like the system isn't running it on boot up, but all the symlinks are there correctly. Wish it would at least give me an error or something but there is nothing in the logs. I am stumped and afraid there isn't anymore info I can give. So anyone who has any idea, no matter how small, please let me know. Also, it runs a Java program that has a Swing GUI, not sure if that is a factor but failed to mention it. I have is set for S99 in the rc?.d so as I understand it that shouldn't be an issue, but then again, I am still new to Linux. Here is the script now to, just in case there is something in it I missed that only messes up on boot up.

    #!/bin/bash
    #
    #

    PATH=/usr/sbin:/usr/bin:/sbin:/bin
    DESC="Chat Server"
    NAME=witchserver

    USER="kitten"
    HOME="/home/kitten"
    CP="/home/kitten/www/witchcraft/chat"
    MAIN="Server.jar"
    PARGS=""

    ARGS="-jar -cp $CP $CP/$MAIN $PARGS"
    #-Djava.awt.headless=true Add before $MAIN if problem occures
    DAEMON="/usr/bin/java"
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME

    # Gracefully exit if the package has been removed.
    test -x /usr/bin/java || exit 0

    # ---------------------------------------
    # Function that starts the daemon/service
    # ---------------------------------------
    d_start()
    {
    start-stop-daemon --start --make-pidfile --background --pidfile $PIDFILE --exec $DAEMON -- $ARGS
    }

    # --------------------------------------
    # Function that stops the daemon/service
    # --------------------------------------
    d_stop()
    {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE
    }

    case "$1" in
    start)
    echo -n "Starting $DESC: $NAME" "$DAEMON"
    d_start
    echo "."
    ;;
    stop)
    echo -n "Stopping $DESC: $NAME"
    d_stop
    echo "."
    ;;
    restart|force-reload)
    echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 1
    d_start
    echo "."
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
    esac

    exit 0
    Last edited by KittenKoder; 09-16-2008 at 11:02 PM.

  11. #11
    Join Date
    Sep 2008
    Posts
    11

    All Better Now

    Negate this, I feel like a dolt. Too use to everything being GUI based, became lazy by Windoze. It was the Swing GUI code that was messing it up the whole time. For daemons Swing doesn't work, now I know. Thanks for those that tried to help, it was all my own laziness that caused the problem though.

  12. #12
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    It's not just Swing that will have that problem: *any* GUI program will have that problem. You can't show a GUI until you (a) have an X server running on the machine (or some other machine that will accept connections from the program), and (b) tell the program where its X server is.

    Before you log in, you don't have an X server running.

    All boot scripts run before you log in. (Or at least, it's safest to assume that they do. Depending on the distro, some of them may run after login, but if your distro is able to do this at all, then it's also undefined when exactly the scripts run. So on one run it may be after you log in, but the next it may not be.)

    That's pretty much the entire problem.

    It may work to try the -Djava.awt.headless=true option from the script's comments. I don't know if that will work or not; it depends on what the Java program does exactly. But it sounds like it might possibly let the program come up even if it doesn't have any way to show a GUI.

  13. #13
    Join Date
    Sep 2008
    Posts
    11
    Thanks, I will make note of that in case I run into the problem again. Most documentation I find is either a collection of links, going to more collections of links, etc. and I just get annoyed having to keep clicking on a lot of links just to get one answer to something that should be simple. Now I just have to figure out differences between the distros from Ubuntu so I can create the server Java app auto launchers for them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •