[SATLUG] haldaemon restart at boot

Tweeks tweeksjunk2 at theweeks.org
Fri Nov 20 00:34:58 CST 2009


On Wednesday 18 November 2009 11:50:53 pm Bruce Dubbs wrote:
[...]
> > The "98" number is the start order.. Change it to 99 to make it start up
> > last. :)
>
> Not 100% precise.  If there are other scripts at 99 that start with a
> string found later in the alphabet than 'haldaemon', those will be
> started later.  For instance:

I figured it would be you to point it out BRUUUUUCE... 
;)



> Now if you named the script with something non-standrd like
> SZ99haldaemon, it would indeed start last.  The scripts are run in the
> order returned by:
>
>   /etc/rc$runlevel.d/S*
>
> Yes, its a nitpick, but something I think should be understood by anyone
> who want to change the order of initialization scripts.

If you want to be hyper-accurate Bruce.. you left a couple nits 
unpicked.

Depending on what distro you're using, init script system can vary quite a bit.
By doing your renaming hack, the symlink can break other parts of the system.

For example, the Red Hat chkconfig automation system.  Your hack 
would have left chkconfig crippled like this:  

	# chkconfig --list haldaemon
	haldaemon        0:off   1:off   2:on    3:off   4:on    5:on    6:off

Sorry Bruce... my nit now.. ;)


> For more information, read the script /etc/rc.d/rc on a RedHat system.

A better "hack" that WOULDN'T break the a Red Hat system would 
be to use the system to hack itself, but correctly.  

For example.. on a RH system, instead of hacking the symlink (illegally), 
play within the bounds of the chkconfig system: 
-Delete (tear down) the SysV symlinks, 
-RENAME the init script itself, 
-then properly modify it's start and stop order number, 
-then rebuild the links with the chkconfig add command

So to do it correctly, first remove the SysV init script symlinks by
using the RH "chkconfig --del" command, but don't actually stop it:
	
	# ls -la /etc/rc.d/rc3.d/*hal*
	lrwxrwxrwx 1 root root 19 Nov 19 23:56 /etc/rc.d/rc3.d/S98haldaemon -> ../init.d/haldaemon
	# chkconfig --del haldaemon
	# ls -la /etc/rc.d/rc3.d/*hal*
	ls: /etc/rc.d/rc3.d/*hal*: No such file or directory

Now rename the actual SysV init script to make it last alphabetically:

	# mv /etc/rc.d/init.d/haldaemon /etc/rc.d/init.d/ZZhaldaemon

Next, modify these "comment lines" in the init script:

	# chkconfig: 345 98 02
to
	# chkconfig: 345 99 02

(the 98 was the OLD start order.. now 99 is)

Now use chkconfig to add (and rebuild) the valid start links using 
its new service name:
	# chkconfig --add ZZhaldaemon
	# chkconfig --list |grep ZZ
	ZZhaldaemon     0:off   1:off   2:off   3:on    4:on    5:on    6:off

While still showing the new correctly modified start order:

 	# ls -la /etc/rc.d/rc3.d/*hal*
	lrwxrwxrwx 1 root root 21 Nov 20 00:02 /etc/rc.d/rc3.d/S99ZZhaldaemon -> ../init.d/ZZhaldaemon

You might also want to add the "hal" package to the yum skiplist to prevent it 
from being changed via some future update.  

NOW the system is "good" and you have avoided setting up someone else da bomb.

That is.. unless you want prevent from updating by maybe creating and hacking 
a decoy init script that can't be upgraded:
	touch /etc/rc.d/init.d/haldaemon && chattr +i /etc/rc.d/init.d/haldaemon

hehe.. (that was a joke).. ;)


L8ERs...

Tweeks


More information about the SATLUG mailing list