Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 4222 - A couple of extra scripts for Gentoo's RC system
Summary: A couple of extra scripts for Gentoo's RC system
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
: 2467 5820 7123 7141 12479 (view as bug list)
Depends on: 2462
Blocks: 5820
  Show dependency tree
 
Reported: 2002-06-26 23:04 UTC by Sean E Russell
Modified: 2003-08-04 11:31 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
A script to provide summary information about the system RC status (rc-status,8.58 KB, text/plain)
2002-06-26 23:06 UTC, Sean E Russell
Details
A really, really small script that is really, really convenient. (service,54 bytes, text/plain)
2002-06-26 23:07 UTC, Sean E Russell
Details
A patch to catch missing directories in /mnt/.init.d (rc-status.patch,1.55 KB, patch)
2002-06-27 21:20 UTC, Sean E Russell
Details | Diff
Incremental patch to fix nil error (rc-status.patch.2,776 bytes, patch)
2002-06-28 11:40 UTC, Sean E Russell
Details | Diff
the /usr/sbin/rc-status script rewritten in bash (rc-status-bash,8.91 KB, text/plain)
2002-08-02 07:49 UTC, SpanKY
Details
rc-update patch to list services (rc-update.show.patch,1.20 KB, patch)
2002-12-30 02:14 UTC, Max Kalika (RETIRED)
Details | Diff
updated rc-status (works with latest baselayout) (rc-status,7.53 KB, text/plain)
2003-02-16 20:46 UTC, SpanKY
Details
more touchups (rc-status,6.70 KB, text/plain)
2003-02-16 20:49 UTC, SpanKY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sean E Russell 2002-06-26 23:04:12 UTC
Here are a couple of scripts which I find useful. 
 
The first is trivial; it is a port of Redhat's (& Mandrake's) 'service' script.  
It's all of three lines.  It allows the user to say 'service qmail restart' 
rather than '/etc/init.d/qmail restart', and it is amazingly handy for such a 
stupid little script.  The reason being that it is much easier to type.  Try 
it, you'll like it.  The script is in /bin/sh. 
 
The second script is more substantial.  I call this script rc-status, and it 
prints information about the rc services that are installed and their run 
status.  This provides an /overview/ of the RC system.  I find that it is very 
easy to have 'orphaned' init.d scripts; scripts which were installed, but never 
'enabled' with rc-update.  It took me a good three days after first installing 
Gentoo to realize that cron wasn't enabled by default :-/.  In any case, this 
script can be used to show the status of all services defined at this runlevel, 
as well as print out a list of all services which are installed but not enabled. 
 
By default, the script displays information about the current run level.  If a 
symbolic name is provided, it displays information about that run level 
instead.  If --all (-a) is provided, it displays information about all run 
levels, including 'orphaned' services.  If --unused (-u) is provided, it 
displays a list of services which are installed, but not assigned to any run 
level.  --help (-h) displays usage information.  --list (-l) shows a list of all 
run level symbolic names defined for the system.  --nocolors (-n) turns off 
colors in the output. 
 
The script is written in Ruby.  I don't do Python.  I commented it copiously, 
so if someone wants to do a conversion to Python, it shouldn't be difficult.  
There are 91 lines of non-blank, non-comment code; 185 with comments.  You 
could redo it in /bin/sh; more power to you.  I've got a low threshold for 
pain, so it is in Ruby. 
 
I'd like to see these either in baselayout, or one of the extension libraries, 
such as gentoolkit.  Wherever is appropriate.  I hesitate to make an entire 
ebuild for these two scripts, but I will if I need to. 
 
Thanks.
Comment 1 Sean E Russell 2002-06-26 23:06:10 UTC
Created attachment 1828 [details]
A script to provide summary information about the system RC status
Comment 2 Sean E Russell 2002-06-26 23:07:26 UTC
Created attachment 1829 [details]
A really, really small script that is really, really convenient.
Comment 3 SpanKY gentoo-dev 2002-06-27 19:16:06 UTC
rux0r root # rc-status
/usr/sbin/rc-status:149:in `open': No such file or directory -
 "/mnt/.init.d/failed" (Errno::ENOENT)
        from /usr/sbin/rc-status:149:in `entries'
        from /usr/sbin/rc-status:149
Comment 4 Sean E Russell 2002-06-27 21:17:00 UTC
Hmm.  I didn't know that /mnt/.init.d/failed (and I'd assume /mnt/.init.d/broken) was an optional directory.  I thought they were part of the rc system.  In any case, I've attached a patch that fixes this problem, and ignores those directories if they don't exist. 
Comment 5 Sean E Russell 2002-06-27 21:20:11 UTC
Created attachment 1843 [details, diff]
A patch to catch missing directories in /mnt/.init.d
Comment 6 SpanKY gentoo-dev 2002-06-27 22:38:36 UTC
if you need more info about my setup to make this work, just ask

rux0r root # rc-status
Runlevel: default
  local                                                             [ started ]
  netmount                                                          [ started ]
  net.eth0                                                          [ started ]
  sshd                                                              [ started ]
  samba                                                             [ started ]
  metalog                                                           [ started ]
  dcron                                                             [ started ]
/usr/sbin/rc-status:176: undefined method `include?' for nil (NameError)
        from /usr/sbin/rc-status:171:in `each'
        from /usr/sbin/rc-status:171
        from /usr/sbin/rc-status:167:in `each'
        from /usr/sbin/rc-status:167
  apache
Comment 7 Sean E Russell 2002-06-28 11:40:01 UTC
Created attachment 1855 [details, diff]
Incremental patch to fix nil error

This bug that vapier is seeing really shouldn't occur; it can't, theoretically,
occur.	However, this patch ensures that it doesn't occur.
Comment 8 SpanKY gentoo-dev 2002-06-28 13:11:19 UTC
i cant test out that patch on rux0r (the ps went up in smoke, literally) ...

ill tested it out on my desktop and it worked great :)
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-28 15:05:19 UTC
*** Bug 2467 has been marked as a duplicate of this bug. ***
Comment 10 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-28 15:10:26 UTC
Ok, just got home, and yesterday evening the power was out the whole night :(

Anyhow, rc-status looks like a gem, which we can either have in baselayout,
or maybe gentoolkit (will have to check with Karl).  Side note though, is if
in baselyout, ill rather like to have it in bash, using /etc/init.d/functions.sh
for output.  We can even change eend() to have a third optional parameter to
change the default output (ok, or status, etc).  My ruby sux though :/

Then for the service script.  We have talked about this before, and I dont like
it .. many other users/developers dont like it, or feel it is not safe (dont
want initscripts in $PATH).  I really feel it is a user-domain thing .. if
you want it, you can do the 3 lines of bash code.
Comment 11 SpanKY gentoo-dev 2002-06-28 15:29:54 UTC
Martin Schlemmer: where do you live ? my power went out last evening also ;)
which leads to why rux0r's PS went up in smoke

at any rate i would have to agree on both points ...
rc-status *should* be in bash (i lub bash, i had to bring down ruby on my boxes 
in order to test out your script)
the service thing should be a user preference ... if you want it, add the 3 
lines ... hell, make it an alias for the super user in /etc/profile ;)
Comment 12 Sean E Russell 2002-06-28 16:23:03 UTC
'bash' /is/ the LCD, and there's good reason to have only bash scripts in the 
baselayout.  That said: 
  
1) All non-trivial bash scripts inevitably becoume unmanageable.  rc-status  
wouldn't be exactly trivial to implement in bash.  Therefore, I'd personally 
rather see it in gentoolkit than in baselayout if bashness is a prerequisite 
for baselayout. 
 
2) rc-status isn't exactly a core feature; nobody is going to die for not 
having rc-status installed. Another argument for having it in gentoolkit. 
 
3) If someone else wants to rewrite it in bash, that is fine by me.  I'm not  
going to do it, though :-)  
 
Martin sez: 
> for output.  We can even change eend() to have a third optional parameter to  
> change the default output (ok, or status, etc).  My ruby sux though :/  
 
I think the array operations would be the most complicated thing to translate 
to bash.  I think Python would be a better target for translation.  Most of 
Gentoo depends on Python, so it is installed by default.  I thoroughly dislike 
Python, though, so (again) I won't be doing a translation. 
  
> Then for the service script.  We have talked about this before, and I dont 
> like it .. many other users/developers dont like it 
 
Hm.  Yeah, I just found bug #2467.  Well, I'm coming from Redhat and Mandrake, 
and the 'service' function is a sanity feature.  Anybody who spends any real 
time doing sysadmin knows that you tend to call the rc scripts a lot by hand, 
when you're upgrading, installing, configuring, and fixing.  In any case, I 
don't really care if 'service' makes it into the distribution; I submitted it 
as an enhancement because I don't know of a better place for people to submit 
utility scripts, and as much as some Gentoo users may not like it, a lot of 
people coming from just about any of the other major distros are going to miss 
this basic functionality.  I thought I'd throw it out there. <shrug/> 
 
> or feel it is not safe (dont want initscripts in $PATH). 
 
This, I don't understand.  'service' doesn't put initscripts any nearer to the 
$PATH than prepending the full path does.  It is merely easier to type the word 
'service ' than '/etc/init.d/'. 
 
Oh, and I got the pun, Martin :-) 
Comment 13 Martin Schlemmer (RETIRED) gentoo-dev 2002-06-28 17:49:42 UTC
> 1) All non-trivial bash scripts inevitably becoume unmanageable.  rc-status  
> wouldn't be exactly trivial to implement in bash.  Therefore, I'd personally 
> rather see it in gentoolkit than in baselayout if bashness is a prerequisite 
> for baselayout. 
> 
> 2) rc-status isn't exactly a core feature; nobody is going to die for not 
> having rc-status installed. Another argument for having it in gentoolkit. 
 
> 3) If someone else wants to rewrite it in bash, that is fine by me.  I'm not  
> going to do it, though :-)  

True.

> I think the array operations would be the most complicated thing to translate 
> to bash.  I think Python would be a better target for translation.  Most of 
> Gentoo depends on Python, so it is installed by default.  I thoroughly dislike 
> Python, though, so (again) I won't be doing a translation. 

This was ideas for a bash rewrite.

>> or feel it is not safe (dont want initscripts in $PATH). 
> 
> This, I don't understand.  'service' doesn't put initscripts any nearer to the 
> $PATH than prepending the full path does.  It is merely easier to type the
> word 'service ' than '/etc/init.d/'.

This is not my argument .. just came up with a previous discussion.
 
> Oh, and I got the pun, Martin :-) 

Ok, I dont know what "pun" means ;)
Comment 14 Martin Schlemmer (RETIRED) gentoo-dev 2002-07-16 17:09:19 UTC
Hi Karl .. mind having a look at rc-status for inclusion in gentoolkit?  Thanks.
Comment 15 Dan Naumov 2002-08-01 01:15:28 UTC
I haven't tried this as I don't have Ruby installed, but from what I read here,
I'd vote for thsi to be re-writted in something that would allow it's inclusion
in the base system. To be honest, I don't understand why gentoolkit is not a
part of it either. Yes, you CAN survive without gentoolkit installed, but it's
small and who would NOT WANT to have it installed ?
Comment 16 SpanKY gentoo-dev 2002-08-02 07:49:12 UTC
Created attachment 2738 [details]
the /usr/sbin/rc-status script rewritten in bash

since everyone wants it but noone wants to do it, please test this out and tell
me it works ;)
also, please audit the source code real quick as this is the first real bash
script ive done that doesnt consist of just 1 or 2 if statements
Comment 17 Martin Schlemmer (RETIRED) gentoo-dev 2002-08-07 16:35:20 UTC
*** Bug 5820 has been marked as a duplicate of this bug. ***
Comment 18 SpanKY gentoo-dev 2002-08-27 11:15:32 UTC
*** Bug 7123 has been marked as a duplicate of this bug. ***
Comment 19 SpanKY gentoo-dev 2002-08-27 18:52:43 UTC
*** Bug 7141 has been marked as a duplicate of this bug. ***
Comment 20 SpanKY gentoo-dev 2002-12-20 09:46:29 UTC
*** Bug 12479 has been marked as a duplicate of this bug. ***
Comment 21 Matt Taylor 2002-12-20 23:20:49 UTC
I found this from Bug 12479, tested and it works great.  Whats the status of
this?  Is it going to be included in gentoolkit or what?
Comment 22 Max Kalika (RETIRED) gentoo-dev 2002-12-30 02:14:33 UTC
Created attachment 6847 [details, diff]
rc-update patch to list services

I know there were previous attempts at getting this functionality for
rc-update.  This is just an idea.  It adds a "show" command-line arg to
rc-update, which lists all available scripts in /etc/init.d and the runlevels
for which they'll execute.  If no runlevels are specified, rc-update will list
all runlevels otherwise just specified runlevels will be shown.  This patch
also ignores any .sh functionality scripts in /etc/init.d.

please be gentle... :-)
Comment 23 SpanKY gentoo-dev 2003-02-16 13:22:27 UTC
taking so i can add it 
Comment 24 SpanKY gentoo-dev 2003-02-16 20:46:48 UTC
Created attachment 8349 [details]
updated rc-status (works with latest baselayout)

actually i lied, it doesnt belong in gentoolkit, it belongs in baselayout ...
back to you az ;)
Comment 25 SpanKY gentoo-dev 2003-02-16 20:49:30 UTC
Created attachment 8350 [details]
more touchups
Comment 26 Martin Schlemmer (RETIRED) gentoo-dev 2003-08-04 11:31:41 UTC
Added to CVS (or about to), thanks guys.  Sorry for being so long overdue ...