/[baselayout]/trunk/sbin/init.linux.sh
Gentoo

Contents of /trunk/sbin/init.linux.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2050 - (show annotations) (download) (as text)
Fri Jun 2 20:02:40 2006 UTC (8 years, 1 month ago) by uberlord
File MIME type: text/x-sh
File size: 4985 byte(s)
    Allow LC_* and LANG vars through to runscript.sh by default.

    net.lo now comes after bootmisc, #135118 thanks to Oldrich Jedlicka.

    arping.sh now has MAC address support, #134253 thanks to Oldrich Jedlicka.

    pppd.sh now updates secret files with a blank password, #134337

    Remove swapon call from /sbin/rc as localmount already calls it,
    partial fix for #134489
1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # void single_user()
5 #
6 # Drop to a shell, remount / ro, and then reboot
7 #
8 single_user() {
9 /sbin/sulogin ${CONSOLE}
10 einfo "Unmounting filesystems"
11 if [[ -c /dev/null ]] ; then
12 /bin/mount -a -o remount,ro &>/dev/null
13 else
14 /bin/mount -a -o remount,ro
15 fi
16 einfo "Rebooting"
17 /sbin/reboot -f
18 }
19
20 source "${svclib}"/sh/init-functions.sh
21 source "${svclib}"/sh/init-common-pre.sh
22
23 echo
24 echo -e "${GOOD}Gentoo Linux${GENTOO_VERS}; ${BRACKET}http://www.gentoo.org/${NORMAL}"
25 echo -e " Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2"
26 echo
27 if [[ ${RC_INTERACTIVE} == "yes" ]] ; then
28 echo -e "Press ${GOOD}I${NORMAL} to enter interactive boot mode"
29 echo
30 fi
31 check_statedir /proc
32
33 ebegin "Mounting proc at /proc"
34 if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
35 mntcmd=$(get_mount_fstab /proc)
36 else
37 unset mntcmd
38 fi
39 try mount -n ${mntcmd:--t proc proc /proc}
40 eend $?
41
42 # Read off the kernel commandline to see if there's any special settings
43 # especially check to see if we need to set the CDBOOT environment variable
44 # Note: /proc MUST be mounted
45 [[ -f /sbin/livecd-functions.sh ]] && livecd_read_commandline
46
47 if [[ $(get_KV) -ge "$(KV_to_int '2.6.0')" ]] ; then
48 if [[ -d /sys ]] ; then
49 ebegin "Mounting sysfs at /sys"
50 if [[ ${RC_USE_FSTAB} == "yes" ]] ; then
51 mntcmd=$(get_mount_fstab /sys)
52 else
53 unset mntcmd
54 fi
55 try mount -n ${mntcmd:--t sysfs sysfs /sys}
56 eend $?
57 else
58 ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!"
59 fi
60 fi
61
62 check_statedir /dev
63
64 devfs_automounted="no"
65 if [[ -e "/dev/.devfsd" ]] ; then
66 # make sure devfs is actually mounted and it isnt a bogus file
67 devfs_automounted=$(awk '($3 == "devfs") { print "yes"; exit 0 }' /proc/mounts)
68 fi
69
70 # Try to figure out how the user wants /dev handled
71 # - check $RC_DEVICES from /etc/conf.d/rc
72 # - check boot parameters
73 # - make sure the required binaries exist
74 # - make sure the kernel has support
75 if [[ ${RC_DEVICES} == "static" ]] ; then
76 ebegin "Using existing device nodes in /dev"
77 eend 0
78 else
79 fellback_to_devfs="no"
80 case ${RC_DEVICES} in
81 devfs) devfs="yes"
82 udev="no"
83 ;;
84 udev) devfs="yes"
85 udev="yes"
86 fellback_to_devfs="yes"
87 ;;
88 auto|*) devfs="yes"
89 udev="yes"
90 ;;
91 esac
92
93 # Check udev prerequisites and kernel params
94 if [[ ${udev} == "yes" ]] ; then
95 if get_bootparam "noudev" || \
96 [[ ! -x /sbin/udev || ${devfs_automounted} == "yes" || \
97 $(get_KV) -lt "$(KV_to_int '2.6.0')" ]] ; then
98 udev="no"
99 fi
100 fi
101
102 # Check devfs prerequisites and kernel params
103 if [[ ${devfs} == "yes" ]] ; then
104 if get_bootparam "nodevfs" || [[ ${udev} == "yes" ]] || \
105 ! grep -qs '[[:space:]]devfs$' /proc/filesystems ; then
106 devfs="no"
107 fi
108 fi
109
110 # Actually start setting up /dev now
111 if [[ ${udev} == "yes" ]] ; then
112 start_addon udev
113
114 # With devfs, /dev can be mounted by the kernel ...
115 elif [[ ${devfs} == "yes" ]] ; then
116 start_addon devfs
117
118 # Did the user want udev in the config file but for
119 # some reason, udev support didnt work out ?
120 if [[ ${fellback_to_devfs} == "yes" ]] ; then
121 ewarn "You wanted udev but support for it was not available!"
122 ewarn "Please review your system after it's booted!"
123 fi
124 fi
125
126 # OK, if we got here, things are probably not right :)
127 if [[ ${devfs} == "no" && ${udev} == "no" ]] ; then
128 :
129 fi
130 fi
131
132 # From linux-2.5.68 we need to mount /dev/pts again ...
133 if [[ "$(get_KV)" -ge "$(KV_to_int '2.5.68')" ]] ; then
134 have_devpts=$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)
135
136 if [[ ${have_devpts} = "yes" ]] ; then
137 # Only try to create /dev/pts if we have /dev mounted dynamically,
138 # else it might fail as / might be still mounted readonly.
139 if [[ ! -d /dev/pts ]] && \
140 [[ ${devfs} == "yes" || ${udev} == "yes" ]] ; then
141 # Make sure we have /dev/pts
142 mkdir -p /dev/pts &>/dev/null || \
143 ewarn "Could not create /dev/pts!"
144 fi
145
146 if [[ -d /dev/pts ]] ; then
147 ebegin "Mounting devpts at /dev/pts"
148 if [[ ${RC_USE_FSTAB} == "yes" ]] ; then
149 mntcmd=$(get_mount_fstab /dev/pts)
150 else
151 unset mntcmd
152 fi
153 try mount -n ${mntcmd:--t devpts -o gid=5,mode=0620 devpts /dev/pts}
154 eend $?
155 fi
156 fi
157 fi
158
159 source "${svclib}"/sh/init-common-post.sh
160
161 # Have to run this after /var/run is mounted rw, bug #85304
162 if [[ -x /sbin/irqbalance && $(get_KV) -ge "$(KV_to_int '2.5.0')" ]] ; then
163 ebegin "Starting irqbalance"
164 /sbin/irqbalance
165 eend $?
166 fi
167
168 # Setup login records ... this has to be done here because when
169 # we exit this runlevel, init will write a boot record to utmp
170 # If /var/run is readonly, then print a warning, not errors
171 if touch /var/run/utmp 2>/dev/null ; then
172 > /var/run/utmp
173 touch /var/log/wtmp
174 chgrp utmp /var/run/utmp /var/log/wtmp
175 chmod 0664 /var/run/utmp /var/log/wtmp
176 # Remove /var/run/utmpx (bug from the past)
177 rm -f /var/run/utmpx
178 else
179 ewarn "Skipping /var/run/utmp initialization (ro root?)"
180 fi
181
182
183 # vim:ts=4

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20