Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Openrc: how to check service dependency [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
unknown2
n00b
n00b


Joined: 14 Aug 2012
Posts: 29

PostPosted: Thu Sep 20, 2012 12:03 am    Post subject: Openrc: how to check service dependency [SOLVED] Reply with quote

I found out that during boot, xdm service (lightdm) will start after service net.XXX (dhcp) completed.


i expect that xdm should not wait for dhcp to complete. Is there any way/command to check service dependency of a openrc service?


Last edited by unknown2 on Thu Sep 20, 2012 11:37 am; edited 1 time in total
Back to top
View user's profile Send private message
DONAHUE
Watchman
Watchman


Joined: 09 Dec 2006
Posts: 7651
Location: Goose Creek SC

PostPosted: Thu Sep 20, 2012 3:51 am    Post subject: Reply with quote

Code:
nano /etc/init.d/xdm

_________________
Defund the FCC.
Back to top
View user's profile Send private message
unknown2
n00b
n00b


Joined: 14 Aug 2012
Posts: 29

PostPosted: Thu Sep 20, 2012 11:37 am    Post subject: Reply with quote

DONAHUE wrote:
Code:
nano /etc/init.d/xdm


thanks. i found the problem. xdm depends on netmount, netmount depends on eth.XXX


but i need to review almost every script file in /etc/init.d, this is crazy 8O
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Sun Sep 23, 2012 1:26 am    Post subject: Reply with quote

unknown2 wrote:
but i need to review almost every script file in /etc/init.d, this is crazy

Here's what I use to inspect initscript dependencies.
It's my /root/.bashrc but you can stick it into /etc/bash/bashrc or your own ~/.bashrc ofc. I wrote it to be POSIX-sh compliant, so it should work in busybox too (apart from the first line, which is nothing to do with the functions, but just testing that the shell is interactive: a case construct would be used in POSIX sh.)
Code:
[[ $- = *i* ]] || return
## init.d functions
# you can add other directories (space-separated) in here
readonly INIT_D_DIR='/etc/init.d'
# show a function from initscript/s (and/or glob/s eg 's*')
ifunc(){
   local d f r s=$1 fn="^[[:blank:]]*$1"'\(\)' br='[[:blank:]]*\{'
   shift
   for d in $INIT_D_DIR; do
      for g; do
         for f in "$d/"$g; do
            [ -f "$f" ] || continue
            r=$(sed -En "/$fn($br)?/,/^}/{/^}/q;/$fn$br/n;/$fn/{N;n;};p}" "$f")
            [ "$r" ] && printf '%s\n%s\n' "$f: $s" "$r"
         done
      done
   done
}
# convenience wrappers for the common funcs
idepend(){
   ifunc depend "$@"
}
istart(){
   ifunc start "$@"
}
istop(){
   ifunc stop "$@"
}
ireload(){
   ifunc reload "$@"
}
icheckconfig(){
   ifunc checkconfig "$@"
}

# show the functions defined by an initscript/glob, or all if no args
ishow(){
   local d f
   for d in $INIT_D_DIR; do
      if [ "$*" ]; then
         for f; do
            [ "$f" ] && _ishow "$d/$f"
         done
      else _ishow "$d/*"
      fi
   done
}
_ishow(){
   grep -H '^[[:blank:]]*[[:alpha:]_][[:alnum:]_]*()' $1 | {
      curr=
      while IFS='    :' read -r fname func _; do
         [ "$curr" = "$fname" ] || {
            [ "$curr" ] && echo "${curr##*/}:$f"
            curr=$fname f=
         }
         f+=" ${func%%'()'*}"
      done
      [ "$curr" ] && echo "${curr##*/}:$f"
   }
}

I knocked the above up while I was updating my udev initscript after the last udev upgrade. I wanted udev to start as soon after localmount as possible, and to do that I needed to inspect the dependency tree, exactly like you've been doing:
Code:
$ idepend xdm
/etc/init.d/xdm: depend
        need localmount xdm-setup

        # this should start as early as possible
        # we can't do 'before *' as that breaks it
        # (#139824) Start after ypbind and autofs for network authentication
        # (#145219 #180163) Could use lirc mouse as input device
        # (#70689 comment #92) Start after consolefont to avoid display corruption
        # (#291269) Start after quota, since some dm need readable home
        # (#390609) gdm-3 will fail when dbus is not running
        # (#366753) starting keymaps after X causes problems
        after bootmisc consolefont modules netmount
        after readahead-list ypbind autofs openvpn gpm lircmd
        after quota keymaps
        before alsasound

        # Start before X
        use consolekit dbus xfs

To see what functions are in an initscript, use ishow:
Code:
$ ishow xdm
xdm: depend setup_dm vtstatic start stop

And ifunc to see what a script-specific function does:
Code:
$ ifunc vtstatic xdm
/etc/init.d/xdm: vtstatic
        if [ -e /etc/inittab ] ; then
                grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
        elif [ -e /etc/ttys ] ; then
                grep -q "^ttyv$(($1 - 1))" /etc/ttys
        else
                return 1
        fi

Note that these take standard shell parameters, so you can check multiple initscripts at a time, eg idepend xdm udev and istart /usr/local/etc/init.d/web*.

They also take globs if you quote them so the shell doesn't expand them as files in the current directory. For example ireload 'sys*' here shows me here that out of sysctl, sysfs and syslog-ng, only the last has a reload function, which is ofc what we'd expect, and what that function does. So the last example above would be better handled by putting the directory in the INIT_D_DIR variable at the top and using: istart 'web*' instead.

HTH: it certainly helped me to track down what exactly was going on in the openrc deptree.

Regards,
SteveL.
_________________
creaker wrote:
systemd. It is a really ass pain

update - "a most excellent portage wrapper"

#friendly-coders -- We're still here for you™ ;)
Back to top
View user's profile Send private message
hujuice
Guru
Guru


Joined: 16 Oct 2007
Posts: 318
Location: Rome, Italy

PostPosted: Mon Jan 07, 2013 12:44 pm    Post subject: Reply with quote

unknown2, you're not alone.
See this discussion: https://bugs.gentoo.org/show_bug.cgi?id=439092

Regards,
HUjuice
_________________
Who hasn't a spine, should have a method.
Chi non ha carattere, deve pur avere un metodo.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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