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

Contents of /trunk/sh/runscript.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2763 - (show annotations) (download) (as text)
Tue Jul 10 19:09:41 2007 UTC (7 years, 3 months ago) by uberlord
File MIME type: text/x-sh
File size: 2088 byte(s)
init scripts and their extra options can now have descriptions, #184327.
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 # Descript the init script to the user
21 describe() {
22 if [ -n "${description}" ] ; then
23 einfo "${description}"
24 else
25 ewarn "No description for ${SVCNAME}"
26 fi
27
28 local svc= desc=
29 for svc in ${opts} ; do
30 eval desc=\$description_${svc}
31 if [ -n "${desc}" ] ; then
32 einfo "${HILITE}${svc}${NORMAL}: ${desc}"
33 else
34 ewarn "${HILITE}${svc}${NORMAL}: no description"
35 fi
36 done
37 }
38
39 [ "${RC_DEBUG}" = "yes" ] && set -x
40
41 # If we're net.eth0 or openvpn.work then load net or openvpn config
42 rc_c=${SVCNAME%%.*}
43 if [ -n "${rc_c}" -a "${rc_c}" != "${SVCNAME}" ] ; then
44 if [ -e "/etc/conf.d/${rc_c}.${RC_SOFTLEVEL}" ] ; then
45 . "/etc/conf.d/${rc_c}.${RC_SOFTLEVEL}"
46 elif [ -e "/etc/conf.d/${rc_c}" ] ; then
47 . "/etc/conf.d/${rc_c}"
48 fi
49 fi
50 unset rc_c
51
52 # Overlay with our specific config
53 if [ -e "/etc/conf.d/${SVCNAME}.${RC_SOFTLEVEL}" ] ; then
54 . "/etc/conf.d/${SVCNAME}.${RC_SOFTLEVEL}"
55 elif [ -e "/etc/conf.d/${SVCNAME}" ] ; then
56 . "/etc/conf.d/${SVCNAME}"
57 fi
58
59 # Load any system overrides
60 [ -e /etc/rc.conf ] && . /etc/rc.conf
61
62 # Apply any ulimit defined
63 [ -n "${RC_ULIMIT}" ] && ulimit ${RC_ULIMIT}
64
65 # Load our script
66 . $1
67
68 shift
69
70 while [ -n "$1" ] ; do
71 # See if we have the required function and run it
72 for rc_x in describe start stop ${opts} ; do
73 if [ "${rc_x}" = "$1" ] ; then
74 if type "$1" >/dev/null 2>/dev/null ; then
75 unset rc_x
76 "$1" || exit $?
77 shift
78 continue 2
79 else
80 if [ "${rc_x}" = "start" -o "${rc_x}" = "stop" ] ; then
81 exit 0
82 else
83 eerror "${SVCNAME}: function \`$1' defined but does not exist"
84 exit 1
85 fi
86 fi
87 fi
88 done
89 eerror "${SVCNAME}: unknown function \`$1'"
90 exit 1
91 done
92
93 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20