Re: SysV init scripts
Fernando <alegre@saturn.superlink.net> writes:
> As a proof of concept I quickly wrote a tiny C program to go through
> the /etc/rc?.d and /etc/init.d directories and output a list with one line
> for each file in /etc/init.d with the format:
>
> script {level}{S/K}{order} ...
>
> where level is the run-level of the link, S/K is the type of link (start or
> kill) and order is the number after the S or K. As an example, the entry
> for xdm in my system looks as follows:
>
> xdm 0K01 1K01 2S99 3S99 4S99 5S99 6K01
This is a nice little format for querying the current state of one's
configuration.
> This program also does the opposite, i.e., it takes input in that form from
> a file and re-arranges the symlinks in /etc/rc?.d accordingly. Since it is
> written in C, it does it real fast.
>
> One could keep a file with the local symlink policy and run it after upgrading
> packages messing with the symlinks to re-enforce it. The program only touches
> the files explicitely listed. All other symlinks are left intact. The program
> does, however, warn upon finding dangling symlinks, entries which are not
> symlinks in an rc?.d directory or symlinks pointing to places other than
> ../init.d/whatever.
Quoting from the manual page for update-rc.d(8)...
If any links /etc/rcrunlevel.d/??name already exist then
update-rc.d does nothing. This is so that the system
administrator can rearrange the links, provided that they
leave at least one link remaining, without having their
configuration overwritten.
And further on...
When invoked with the remove option, update-rc.d removes
any links in the /etc/rcrunlevel.d directories to the
script /etc/init.d/name. The script must have been
deleted already - update-rc.d checks for this.
So, I think this second part of your tool is already handled.
> If you think it would be useful let me know and I will send it to the list.
I'd like to see the reporting bit.
Best wishes,
Kenny.
Reply to: