/[baselayout]/trunk/sh/init-functions.sh
Gentoo

Contents of /trunk/sh/init-functions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (7 years, 8 months ago) by uberlord
File MIME type: text/x-sh
File size: 1259 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 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # void try(command)
5 #
6 # Try to execute 'command', if it fails, drop to a shell.
7 #
8 try() {
9 local errstr
10 local retval=0
11
12 if [ -c /dev/null ] ; then
13 errstr=$(eval $* 2>&1 >/dev/null)
14 else
15 errstr=$(eval $* 2>&1)
16 fi
17 retval=$?
18 if [ ${retval} -ne 0 ] ; then
19 #splash "critical" &
20 eend 1
21 eerror "The \"$*\" command failed with error:"
22 eerror " ${errstr#*: }"
23 echo
24 eerror "Since this is a critical task, startup cannot continue."
25 echo
26 single_user
27 fi
28
29 return ${retval}
30 }
31
32 # bool check_statedir(dir)
33 #
34 # Check that 'dir' exists, if not, drop to a shell.
35 #
36 check_statedir() {
37 [ -z "$1" ] && return 0
38
39 if [ ! -d "$1" ] ; then
40 if ! mkdir -p "$1" &>/dev/null ; then
41 #splash "critical" &
42 echo
43 eerror "For Gentoo to function properly, \"$1\" needs to exist."
44 if [ "${RC_FORCE_AUTO}" = "yes" ] ; then
45 eerror "Attempting to create \"$1\" for you ..."
46 mount -o remount,rw /
47 mkdir -p "$1"
48 fi
49 if [ ! -d "$1" ] ; then
50 eerror "Please mount your root partition read/write, and execute:"
51 echo
52 eerror " # mkdir -p $1"
53 echo; echo
54 single_user
55 fi
56 fi
57 fi
58
59 return 0
60 }
61
62 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20