Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian Development (http://www.linux-archive.org/debian-development/)
-   -   File naming of scripts in /etc/init.d (http://www.linux-archive.org/debian-development/676834-file-naming-scripts-etc-init-d.html)

"Steve R. Petruzzello" 06-25-2012 11:51 AM

File naming of scripts in /etc/init.d
 
Hi,

I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some are
not. On my sytem:

host:/etc/init.d# ls -1 *.sh
bootmisc.sh
checkfs.sh
checkroot.sh
console-screen.sh
hostname.sh
hwclock.sh
keymap.sh
mountall-bootclean.sh
mountall.sh
mountdevsubfs.sh
mountkernfs.sh
mountnfs-bootclean.sh
mountnfs.sh
mtab.sh
umountnfs.sh

All except console-screen.sh, hwclock.sh and keymap.sh are from the initscripts
package.

I was wandering if there was a reason from this discrepancy. So I had a look in
the Debian Policy Manuel, and one can read (subsection 9.3.2 Writing the
scripts) that "These scripts should be named /etc/init.d/package". I failed to
find another reference to script naming in the rest of the document.

So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named by
their package's name (hwclock.sh is part of the util-linux package). Is there a
reason for this?

Would it be purely aesthetics to clean out these script names?

Thank you for the great job.

Best regards,
Steve


PS: Is there a way to list all packages putting a file in /etc/init.d/?


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20120625115136.GA27673@localhost

Vincent Zweije 06-25-2012 12:04 PM

File naming of scripts in /etc/init.d
 
On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:

|| I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some
|| are not. On my sytem:

[...]

|| So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named
|| by their package's name (hwclock.sh is part of the util-linux package). Is
|| there a reason for this?

IIRC, in the olden unix times scripts with a .sh suffix were sourced
(using ". /etc/init.d/foo.sh") by the main rc shell script instead of
executed (using "/etc/init.d/foo.sh") to save the spawning of a separate
shell, for a little speed.

Nowadays, this is probably no longer necessary. Although, with embedded
stuff, you never know.

Ciao. Vincent.
--
Vincent Zweije <vincent@zweije.nl> | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/> | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] | -- Paul Tomblin on a.s.r.

Tanguy Ortolo 06-25-2012 12:23 PM

File naming of scripts in /etc/init.d
 
Steve R. Petruzzello, 2012-06-25 13:51+0200:
> the Debian Policy Manuel, and one can read (subsection 9.3.2 Writing the
> scripts) that "These scripts should be named /etc/init.d/package". I failed to
> find another reference to script naming in the rest of the document.
>
> So […] 2) some scripts are not named by
> their package's name (hwclock.sh is part of the util-linux package).

About this specific point, while it is relevant to name scripts by the
name of their package, I do not think it should be too strict. Such a
recommendation exists to maintain a bit of order and to avoid conflicts.
However, there are examples of scripts which have a logical name which
is distinct from the name of their package, typically hwclock.sh.

--
,--.
: /` ) Tanguy Ortolo <xmpp:tanguy@ortolo.eu> <irc://irc.oftc.net/Tanguy>
| `-' Debian Developer
\_


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/js9l85$sc$1@dough.gmane.org

Roger Leigh 06-25-2012 01:47 PM

File naming of scripts in /etc/init.d
 
On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:
> I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some are
> not. [...] All except console-screen.sh, hwclock.sh and keymap.sh are from
> the initscripts package.
>
> So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named by
> their package's name (hwclock.sh is part of the util-linux package). Is there
> a reason for this?

Nowadays, it's essentially the case that
- scripts with a .sh suffix are run from rcS
- they are not intended to be run by hand and/or after boot, or
else they can screw up the system state

> Would it be purely aesthetics to clean out these script names?

Yes, though the above distinction about them being run from rcS
would be lost. And given the history, and the fact that other
scripts depend on them (the names are used in the inter-script
dependencies), renaming them is do-able, but not something we
should be doing this close to the freeze.

> PS: Is there a way to list all packages putting a file in /etc/init.d/?

dpkg -S $(ls -1 /etc/init.d/*)


Regards,
Roger

--
.'`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120625134758.GP9135@codelibre.net">http://lists.debian.org/20120625134758.GP9135@codelibre.net

Simon McVittie 06-25-2012 01:57 PM

File naming of scripts in /etc/init.d
 
On 25/06/12 14:47, Roger Leigh wrote:
> On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:
>> PS: Is there a way to list all packages putting a file in /etc/init.d/?
>
> dpkg -S $(ls -1 /etc/init.d/*)

Or if you want the complete set, not just those you have installed,
install apt-file and run:

apt-file update
apt-file search /etc/init.d

Regards,
S


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FE86E32.3070508@debian.org">http://lists.debian.org/4FE86E32.3070508@debian.org

"Steve R. Petruzzello" 06-25-2012 01:59 PM

File naming of scripts in /etc/init.d
 
Le 25-06-2012, à 14:47:58 +0100, Roger Leigh (rleigh@codelibre.net) a écrit :

> On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:
> > I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some are
> > not. [...] All except console-screen.sh, hwclock.sh and keymap.sh are from
> > the initscripts package.
> >
> > So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named by
> > their package's name (hwclock.sh is part of the util-linux package). Is there
> > a reason for this?
>
> Nowadays, it's essentially the case that
> - scripts with a .sh suffix are run from rcS

But not all scripts in /etc/rcS.d/ have a .sh suffix (for instance S09mdadm-raid).


> - they are not intended to be run by hand and/or after boot, or
> else they can screw up the system state
>
> > Would it be purely aesthetics to clean out these script names?
>
> Yes, though the above distinction about them being run from rcS
> would be lost. And given the history, and the fact that other
> scripts depend on them (the names are used in the inter-script
> dependencies), renaming them is do-able, but not something we
> should be doing this close to the freeze.

Sure.

> > PS: Is there a way to list all packages putting a file in /etc/init.d/?
>
> dpkg -S $(ls -1 /etc/init.d/*)


Sorry, I was thinking of the whole archive, not only the installed package.


Thanks,
Steve


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20120625135929.GA16892@localhost

Roger Leigh 06-25-2012 02:21 PM

File naming of scripts in /etc/init.d
 
On Mon, Jun 25, 2012 at 03:59:30PM +0200, Steve R. Petruzzello wrote:
> Le 25-06-2012, à 14:47:58 +0100, Roger Leigh (rleigh@codelibre.net) a écrit :
>
> > On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:
> > > I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some are
> > > not. [...] All except console-screen.sh, hwclock.sh and keymap.sh are from
> > > the initscripts package.
> > >
> > > So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named by
> > > their package's name (hwclock.sh is part of the util-linux package). Is there
> > > a reason for this?
> >
> > Nowadays, it's essentially the case that
> > - scripts with a .sh suffix are run from rcS
>
> But not all scripts in /etc/rcS.d/ have a .sh suffix (for instance S09mdadm-raid).

No, it's not a strict rule, just historic practice. If we were to
do it over today, it's unlikely we would use the suffixed names.


Regards,
Roger

--
.'`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120625142102.GQ9135@codelibre.net">http://lists.debian.org/20120625142102.GQ9135@codelibre.net

"Steve R. Petruzzello" 06-27-2012 08:46 AM

File naming of scripts in /etc/init.d
 
Dear all,

Thank you for your answers.


Le 25-06-2012, à 15:21:02 +0100, Roger Leigh (rleigh@codelibre.net) a écrit :

> On Mon, Jun 25, 2012 at 03:59:30PM +0200, Steve R. Petruzzello wrote:
> > Le 25-06-2012, à 14:47:58 +0100, Roger Leigh (rleigh@codelibre.net) a écrit :
> >
> > > On Mon, Jun 25, 2012 at 01:51:36PM +0200, Steve R. Petruzzello wrote:
> > > > I noticed that some scripts in /etc/init.d/ are suffixed by .sh and some are
> > > > not. [...] All except console-screen.sh, hwclock.sh and keymap.sh are from
> > > > the initscripts package.
> > > >
> > > > So 1) nowhere is .sh suffixing mentioned and 2) some scripts are not named by
> > > > their package's name (hwclock.sh is part of the util-linux package). Is there
> > > > a reason for this?
> > >
> > > Nowadays, it's essentially the case that
> > > - scripts with a .sh suffix are run from rcS
> >
> > But not all scripts in /etc/rcS.d/ have a .sh suffix (for instance S09mdadm-raid).
>
> No, it's not a strict rule, just historic practice. If we were to
> do it over today, it's unlikely we would use the suffixed names.


So my question was not too stupid :)


Best regards,
Steve


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20120627084604.GA8811@localhost


All times are GMT. The time now is 11:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.