-
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.
-
Pid?
Okay, what is the PID and do I have to add one for the script?
-
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.
-
Did you make the script executable?
Assuming it is in /etc/init.d/myscript
Do (as root) chmod +x /etc/init.d/myscript
-
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
-
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
-
Originally Posted by paj12
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.
-
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?
-
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
-
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.
-
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.
-
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.
-
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
-
Forum Rules
|
|