LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-20-2001, 03:20 PM   #1
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Rep: Reputation: 31

Hi, I want to create a script in the init.d directory and then create a link in rc3.d that links to init.d/myscript
Does any one know how to do that in RedHat Linux 7.1. What I though to do is to create another script for the link but wondering if there is another way to do this. BTW this will be used to start things at boot time and stuff.
 
Old 05-20-2001, 04:31 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
ln (source) (target), so
ln -s /etc/rc.d/init.d/myScript /etc/rc.d/rc3.d/SmyScript
watch the _S_ in front of the link in rc3.d, stands for start, K for kill.

Theres no need to create a script for the link, if u want to execute the script conditionally just parse for the conditions from myScript.
 
Old 05-20-2001, 04:34 PM   #3
billsabub
Member
 
Registered: Feb 2001
Posts: 109

Rep: Reputation: 15
Nabil,

You've got most of it already!

Just create the script and place it in the init.d directory. In the rc3.d directory, to create a link to "myscript" in init.d, you would issue this command:

ln -s /etc/init.d/myscript /etc/rc3.d/S55myscript

(note that I put full pathnames to make it easier to keep track).

The -s option creates a symbolic link, which creates a file in your rc3.d directory that points to your script in init.d

HTH.
 
Old 05-20-2001, 04:37 PM   #4
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
What do you mean by "just parse for the conditions from myScript" Can you provide an example. Thanks.
 
Old 05-20-2001, 08:14 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
say u only want to start a script which starts the software watchdog only if dhcpcd is running, then u could try getting the PID for SSHD. The script is always called with an argument and executes 1 test _before_ the passing argument is handled. This fictive script finds out if my kernel version is above 2.2.17 (a bit lame way but it works for me) before continuing and will try to see if the Process ID for dhcpcd is present (-n, not empty), else restart networking and start this script ($0) with the start arg again. if it is present it will start the daemon and finish off the rest of the script. (underscores replace spaces, indentation doesnt work here)

#!/bin/sh

KVER=$(cat /proc/version | gawk '{print $3}' | sed -e "s/[-,A-Z,.,2,1]//g")
if [ $KVER -le 7 ]; then
_______echo "Watchdog: bailing out."
_______exit 1
fi

case "$1" in
_______start)
______________if [ -n $(pidof dhcpcd) ]; then
_____________________/etc/rc.d/init.d/network restart
_____________________$0 start
______________else
_____________________daemon watchdog
_____________________echo "Watchdog: started."
______________fi
______________;;
etc.

everything u can think of can be tested before running stuff; time, diskspace, amount of incoming tcp/ip packages with the TOS bit set to 0x01 0x02...
*be cautious with scripts u didnt write ureself
 
Old 05-20-2001, 09:04 PM   #6
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
Uh.. I got it. Good practices too.
Thanks guys.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create windows like shortcuts in Linux ? indian Linux - General 1 07-29-2005 09:57 AM
Shortcuts and things to make the Linux experience a little bit smoother... Basslord1124 Linux - General 2 03-22-2005 12:45 PM
Linux Dir Shortcuts neozero62 Linux - General 3 01-31-2004 07:30 PM
Shortcuts Thomas_Delrue Linux - Newbie 8 01-03-2004 10:28 AM
shortcuts in linux? keirobyn Linux - General 1 01-21-2002 02:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration