/[baselayout]/trunk/sh/runscript.sh
Gentoo

Contents of /trunk/sh/runscript.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (12 years ago) by uberlord
File MIME type: text/x-sh
File size: 1693 byte(s)
    Rewrite the core parts in C. We now provide librc so other programs can
    query runlevels, services and state without using bash. We also provide
    libeinfo so other programs can easily use our informational functions.

    As such, we have dropped the requirement of using bash as the init script
    shell. We now use /bin/sh and have strived to make the scripts as portable
    as possible. Shells that work are bash and dash. busybox works provided
    you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
    should disable find too.
    zsh and ksh do not work at this time.

    Networking support is currently being re-vamped also as it was heavily bash
    array based. As such, a new config format is available like so
    config_eth0="1.2.3.4/24 5.6.7.8/16"
    or like so
    config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

    We will still support the old bash array format provided that /bin/sh IS
    a link it bash.

    ChangeLog for baselayout-1 can be found in our SVN repo.
1 #!/bin/sh
2 # Shell wrapper for runscript
3 # Copyright 1999-2007 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License v2
5
6 . /etc/init.d/functions.sh
7 . "${RC_LIBDIR}"/sh/rc-functions.sh
8
9 # Support LiveCD foo
10 if [ -r /sbin/livecd-functions.sh ] ; then
11 . /sbin/livecd-functions.sh
12 livecd_read_commandline
13 fi
14
15 if [ -z "$1" -o -z "$2" ] ; then
16 eerror "${SVCNAME}: not enough arguments"
17 exit 1
18 fi
19
20 [ "${RC_DEBUG}" = "yes" ] && set -x
21
22 # If we're net.eth0 or openvpn.work then load net or openvpn config
23 rc_c=${SVCNAME%%.*}
24 if [ -n "${rc_c}" -a "${rc_c}" != "${SVCNAME}" ] ; then
25 if [ -e "/etc/conf.d/${rc_c}.${RC_SOFTLEVEL}" ] ; then
26 . "/etc/conf.d/${rc_c}.${RC_SOFTLEVEL}"
27 elif [ -e "/etc/conf.d/${rc_c}" ] ; then
28 . "/etc/conf.d/${rc_c}"
29 fi
30 fi
31 unset rc_c
32
33 # Overlay with our specific config
34 if [ -e "/etc/conf.d/${SVCNAME}.${RC_SOFTLEVEL}" ] ; then
35 . "/etc/conf.d/${SVCNAME}.${RC_SOFTLEVEL}"
36 elif [ -e "/etc/conf.d/${SVCNAME}" ] ; then
37 . "/etc/conf.d/${SVCNAME}"
38 fi
39
40 # Load any system overrides
41 [ -e /etc/rc.conf ] && . /etc/rc.conf
42
43 # Apply any ulimit defined
44 [ -n "${RC_ULIMIT}" ] && ulimit ${RC_ULIMIT}
45
46 # Load our script
47 . $1
48
49 shift
50
51 while [ -n "$1" ] ; do
52 # See if we have the required function and run it
53 for rc_x in start stop ${opts} ; do
54 if [ "${rc_x}" = "$1" ] ; then
55 if type "$1" >/dev/null 2>/dev/null ; then
56 unset rc_x
57 "$1" || exit $?
58 shift
59 continue 2
60 else
61 if [ "${rc_x}" = "start" -o "${rc_x}" = "stop" ] ; then
62 exit 0
63 else
64 eerror "${SVCNAME}: function \`$1' defined but does not exist"
65 exit 1
66 fi
67 fi
68 fi
69 done
70 eerror "${SVCNAME}: unknown function \`$1'"
71 exit 1
72 done
73
74 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20