Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TIP] Extra rc-update output (started/stopped services)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Po0ky
Tux's lil' helper
Tux's lil' helper


Joined: 21 Apr 2005
Posts: 142
Location: Belgium

PostPosted: Fri Dec 30, 2005 1:30 pm    Post subject: [TIP] Extra rc-update output (started/stopped services) Reply with quote

I've been snoopin arround in the rc-update script and added something to show us if the service is started or stopped.

This will add the state of the services when calling rc-update show.
Code:
                ntpd |      default                  Stopped
             numlock |      default                  Stopped
             postfix |                               Started
           pure-ftpd |                               Started


To achieve this. edit the /sbin/rc-update script (yes, bad me... remember these will be overwritten when updating baselayout)

Add this in the beginning of the file. This will add the functionality to check if the service is loaded. Professionally copy pasted from /sbin/runscript.sh
Code:
[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh"

And then go down a little into the show function
Code:
show() {
    local x=
    local y=
    # More code here...
    for x in ${myscripts}
    do
        if [ "${x%%.sh}" = "${x}" ]
        then
            printf "%20s | " ${x:0:19}
            for y in ${mylevels}
            do
                if [ -L "/etc/runlevels/${y}/${x}" ]
                then
                    echo -n "${y} "
                else
                    printf "%${#y}s " " "

                fi
            done
            service_started ${x}                      ### NEW CODE
            if [ $? == 0 ]                            ### NEW CODE
            then                                      ### NEW CODE
                printf "\033[01;32mStarted\033[00m"   ### NEW CODE
            else                                      ### NEW CODE
                printf "\033[01;31mStopped\033[00m"   ### NEW CODE
            fi                                        ### NEW CODE
            echo ""
        fi
    done
     # More code ...
}


The \033...m things are for colored ouput... feel fee to strip them or change them... now they are green and red 8O
_________________
-- I'll eat it--
Back to top
View user's profile Send private message
Braempje
l33t
l33t


Joined: 31 Jan 2003
Posts: 748

PostPosted: Fri Dec 30, 2005 2:37 pm    Post subject: Reply with quote

You might want to look at rc-status for similar output of only the started services...
_________________
Dictionary of the Flemish Sign Language - Woordenboek Vlaamse Gebarentaal
Back to top
View user's profile Send private message
Po0ky
Tux's lil' helper
Tux's lil' helper


Joined: 21 Apr 2005
Posts: 142
Location: Belgium

PostPosted: Fri Dec 30, 2005 3:24 pm    Post subject: Reply with quote

woops, if I only knew this ;-)
_________________
-- I'll eat it--
Back to top
View user's profile Send private message
scronkey
n00b
n00b


Joined: 19 Jan 2004
Posts: 31

PostPosted: Fri Dec 30, 2005 3:57 pm    Post subject: Reply with quote

rc-status displays the status of services in the current runlevel (started or not)
rc-status -a displays all runlevels and their services

quite handy indeed
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum