LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Shortcuts in Linux ? (https://www.linuxquestions.org/questions/linux-general-1/shortcuts-in-linux-2640/)

nabil 05-20-2001 03:20 PM

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.

unSpawn 05-20-2001 04:31 PM

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.

billsabub 05-20-2001 04:34 PM

Nabil,

You've got most of it already! :D

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.

nabil 05-20-2001 04:37 PM

What do you mean by "just parse for the conditions from myScript" Can you provide an example. Thanks.

unSpawn 05-20-2001 08:14 PM

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

nabil 05-20-2001 09:04 PM

Uh.. I got it. Good practices too.
Thanks guys.


All times are GMT -5. The time now is 09:32 AM.