Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] SMGL and crisis management - coming out the other side

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: nealbirch <nealbirch AT attbi.com>
  • To: eric AT sandall.us
  • Cc: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] SMGL and crisis management - coming out the other side
  • Date: Sun, 20 Oct 2002 22:36:32 -0400

Eric Sandall wrote:
Great job on the init.d spell though - much prefer it to the previous
setup. Am feeling a lot happier about the important init scripts now.

Thanks! Still some work to do. I'm going to put the networking script
back in net-tools, so things will be a bit more consistant, but it will
still have the part that lets you update the network cards

neal


Why are we moving scripts back out of init.d and into other spells? I can
see why for some of them (samba, cups, etc.), but for others (networking,
mount*, etc.) they should stay in init.d, yes?

The functions and mount scripts will stay in the init.d spell, I made a lib file up with a set of functions that does the run level stuff, which I have attached which allows the other scripts to stay where they belong. I will be returning the networking script to net-tools within a few days and adding a local and nfs mount.sh to init.d.

This is a copy of what I sent out before, see what you think:

<from previous mail>
actually I was talking with Jason about using the functions (for cups) and wrote up a little lib_runlevel file for that. I've attached it so you can check it out. I was pretty tired when I wrote it so we need to test it.

(I have since tested and corrected it, it's attached to this.)

The game plan change #33.5b is to have the appropriate spells install the scripts, with a very few exceptions. I'm going to be updating the net-tools spell and a few others to do this, unless someone beats me to it, using the lib_runlevel functions. This makes it more sensible and less dependent on running another spell which could break things so your box don't boot. You all may remember the fiasco with the mount.sh script disappearing, and a few others had their networking.sh script vanish. Bad juju. It was due to the way the init.d spell was originally written. The unforseen consequences were that it called the standard function spells use to reap what was previous installed before recasting; unfortunately, that may not have been what was installed next, ie, if you installed all three scripts, and ran it again, it would pull out all three scripts before installing whatever was selected. If you didn't select the same mount.sh script, you lost it and your box wouldn't boot. bad bad juju.

One of the exceptions will be the mount.sh, init.d will install a mount_local.sh and an mount_nfs.sh to take care of the issue of trying to mount a network fs if your network isn't running. Since e2fsprogs no longer installs mount.sh, this shouldn't cause problems with one spell reaping another spells scripts. which is why we are putting the scripts back in the spells. Make sense?

--
"You can fool some of the people all of the time
--and those are the ones you have to concentrate on!"
GW Bush-- from the N.Y. Times
# lib_runlevel v0.9
# Installs selected scripts and set run levels and priorities
# scripts to be installed require the following:
# SGL-script-version=<date in yearmonthday format>
# if SGL-script-version=custom it will be left alone.
# this sets the run levels and priority for links
# SGL-START:<runlevels separated by space>:S<priority>
# SGL-STOP:<runlevels separated by space>:K<priority>

initdir=/etc/init.d
savetime=$(date +%Y%m%d%k%M)

# function to generate proper symlinks for runlevels
# called by installscript

linkscript ()
{
truncname=$(echo $init_script | cut -d. -f1)
for action in SGL-START SGL-STOP
do
# this pulls the second field to get runlevel
for level in $(grep "# $action" $initdir/$init_script | cut -d: -f2)
do
# this pulls the third field to get priority
pri=$(grep "# $action" $initdir/$init_script | cut -d: -f3)
if [ ! -f /etc/rc$level.d/*$truncname* ]; then
ln -s $initdir/$init_script /etc/rc$level.d/$pri$truncname
else
# this checks if priority is correct if there is an existing symlink
pri2=$(ls /etc/rc$level.d/*$truncname* | sed s/$truncname// | sed
s/\.sh// | cut -d/ -f4)
if [ ! $pri = $pri2 ]; then
rm -f /etc/rc$level.d/*$truncname*
ln -s $initdir/$init_script /etc/rc$level.d/$pri$truncname
fi
fi
done
done
}

# Function to backup existing scripts and install updated ones
# usage is "installscript <scriptname>"
installscript ()
{

# check for syntax
if [ -n "$1" ] && [ -e $SCRIPT_DIRECTORY/$1 ]; then
# set init_script to script name
init_script=$1
sglver=$(grep "# SGL-script-version=" $SCRIPT_DIRECTORY/$init_script
| cut -d= -f2)
if [ -e $initdir/$init_script ]; then
installedver=$(grep "# SGL-script-version=" $initdir/$init_script
| cut -d= -f2)
if [ ! -n "$installedver" ]; then
installedver=$((0))
fi
if [ ! $installedver = custom ] && [ $sglver -gt $installedver ];
then
mv $initdir/$init_script $initdir/$init_script.$savetime
install -m 755 $SCRIPT_DIRECTORY/$init_script $initdir
linkscript $init_script
fi
else
install -m 755 $SCRIPT_DIRECTORY/$init_script $initdir
linkscript $init_script
fi
else
echo "Usage: installscript <scriptname>"
fi

}
# end lib_runlevel



Archive powered by MHonArc 2.6.24.

Top of Page