LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Startup services (https://www.linuxquestions.org/questions/linux-general-1/startup-services-11763/)

Road 01-14-2002 01:44 PM

Startup services
 
The distro I am using has an Xinetd and a bunch of rc.d files. I am trying to get a program to run at startup but I am not sure how to start. Could some one point me in a good direction so I can figure out how to make programs run on startup?

Thanks

:smash:

Had to use the gif!

bluecadet 01-14-2002 01:52 PM

add whatever file you want to /etc/rc.local and it will load on startup. if you're talkign abuot services and similar, you want to enable them properly using sysvinit or somethign like that

Road 01-14-2002 03:10 PM

I thought thats how you do with the old init.d file not the xinit.d. I do not have an rc.local but rather
rc0.d
rc1.d
rc2.d
rc3.d
rc4.d
rc5.d
rc6.d

I could be completely wrong but I thought with the intro of xinitd.d everything changed?

Either way thanks for replying

Road 01-14-2002 08:06 PM

Ahh ok I have it all figured out.

Anybody who needs anytype of help on runlevels and how linux starts up programs on boot should read this, its great!

http://www.penguinmagazine.com/Magazine/This_Issue/0018

I have been searching all day and this was a gold mine!

koningshoed 06-07-2002 04:57 PM

Quoted from the above mentioned article:

"Links beginning with a capital "S" are to be started, whenever the system is entering the given runlevel.

"Links beginning with a capital "K" are to be stopped whenever leaving that runlevel."

Now, the following is my /etc/init.d/rc file, script used to start/stop the services as needed:

********** START /etc/init.d/rc ************************
#! /bin/sh
#
# rc This file is responsible for starting/stopping
# services when the runlevel changes.
#
# Optimization feature:
# A startup script is _not_ run when the service was
# running in the previous runlevel and it wasn't stopped
# in the runlevel transition (most Debian services don't
# have K?? links in rc{1,2,3,4,5} )
#
# Author: Miquel van Smoorenburg <miquels@cistron.nl>
# Bruce Perens <Bruce@Pixar.com>
#
# Version: @(#)rc 2.78 07-Nov-1999 miquels@cistron.nl
#

# Un-comment the following for debugging.
# debug=echo

#
# Start script or program.
#
startup() {
case "$1" in
*.sh)
$debug sh "$@"
;;
*)
$debug "$@"
;;
esac
}

# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
trap ":" INT QUIT TSTP

# Set onlcr to avoid staircase effect.
stty onlcr 0>&1

# Now find out what the current and what the previous runlevel are.

runlevel=$RUNLEVEL
# Get first argument. Set new runlevel to this argument.
[ "$1" != "" ] && runlevel=$1
if [ "$runlevel" = "" ]
then
echo "Usage: $0 <runlevel>" >&2
exit 1
fi
previous=$PREVLEVEL
[ "$previous" = "" ] && previous=N

export runlevel previous

# Is there an rc directory for this new runlevel?
if [ -d /etc/rc$runlevel.d ]
then
# First, run the KILL scripts.
if [ $previous != N ]
then
for i in /etc/rc$runlevel.d/K[0-9][0-9]*
do
# Check if the script is there.
[ ! -f $i ] && continue

# Stop the service.
startup $i stop
done
fi
# Now run the START scripts for this runlevel.
for i in /etc/rc$runlevel.d/S*
do
[ ! -f $i ] && continue

if [ $previous != N ]
then
#
# Find start script in previous runlevel and
# stop script in this runlevel.
#
suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
#
# If there is a start script in the previous level
# and _no_ stop script in this level, we don't
# have to re-start the service.
#
[ -f $previous_start ] && [ ! -f $stop ] && continue
fi
case "$runlevel" in
0|6)
startup $i stop
;;
*)
startup $i start
;;
esac
done
fi
# eof /etc/init.d/rc
***********************end***********************

Now, I'm aware my scripting is far from the best but like I understand the script, it'll run the kill scripts in the *new* runlevel? This seems wrong for me, as I understood it like the article said, and then I tried it that way - and for the first time in dunno how long - my trusted debian linux crashed on me when switching levels.

Any/all help *very* welcome.

acid_kewpie 06-07-2002 05:34 PM

PLEASE PLEASE PLEASE do NOT drag up long dead threads. thanks.


All times are GMT -5. The time now is 01:42 PM.