/[baselayout]/trunk/sbin/init
Gentoo

Contents of /trunk/sbin/init

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (show annotations) (download)
Tue Aug 21 03:21:56 2001 UTC (11 years, 10 months ago) by drobbins
File size: 3891 byte(s)
many fixes

1 #!/bin/bash
2 trap ":" INT QUIT TSTP
3 source /etc/init.d/functions.sh
4 #no /usr yet, very likely
5 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
6 umask 022
7
8 try() {
9 eval $*
10 if [ $? -ne 0 ]
11 then
12 echo -e "$ENDCOL$NORMAL[$BAD oops $NORMAL]"
13 echo
14 echo '!!! '"ERROR: the $1 command did not complete successfully."
15 echo '!!! '"(\" ${*} \")"
16 echo '!!! '"Since this is a critical task, startup cannot continue."
17 echo
18 /sbin/sulogin $CONSOLE
19 reboot -f
20 fi
21 }
22
23 mountshm() {
24 ebegin "Mounting tmpfs at /dev/shm"
25 try mount -n -t tmpfs tmpfs /dev/shm -o rw,mode=0644,size=4m
26 eend
27 install -d -m0755 /dev/shm/etc
28 #set up mtab script
29 touch /dev/shm/etc/mtab.sh
30 chmod 0644 /dev/shm/etc/*
31 echo mount -f / >> /dev/shm/etc/mtab.sh
32 echo mount -f -t tmpfs tmpfs /dev/shm -o rw,mode=0644,size=4m >> /dev/shm/etc/mtab.sh
33 echo mount -f --bind /dev /dev-state >> /dev/shm/etc/mtab.sh
34 # local swaptot
35 # local tmpfsmax
36 # if [ ! -e /proc/meminfo ]
37 # then
38 # tmpfsmax=4
39 # else
40 # swaptot=`cat /proc/meminfo | sed -n -e '/^Mem:/{s/\(Mem:\)[[:space:]]*\([[:digit:]]*\) \(.*\)/\2/;p}'`
41 # swaptot=$(( $swaptot / 1024000 ))
42 # tmpfsmax=$(( $swaptot / 2 ))
43 # if [ $tmpfsmax -lt 4 ]
44 # then
45 # tmpfsmax=4
46 # fi
47 # fi
48 # echo ebegin "Limiting tmpfs size to ${tmpfsmax}Mb" >> /dev/shm/etc/mtab.sh
49 # #hopefully, this will avoid the "tmpfs not mounted" error
50 # echo mount -t tmpfs tmpfs /dev/shm -o remount,size=${tmpfsmax}m >> /dev/shm/etc/mtab.sh
51 # echo eend \$? >> /dev/shm/etc/mtab.sh
52 echo mount -f /proc >> /dev/shm/etc/mtab.sh
53 echo mount -f -t devfs none /dev >> /dev/shm/etc/mtab.sh
54 }
55
56 if [ $$ -ne 1 ]
57 then
58 exec /sbin/init.system $*
59 fi
60
61
62 echo
63 echo -e "${GOOD}Gentoo Linux${GENTOO_VERS}; \e[34;01mhttp://www.gentoo.org${NORMAL}\n Copyright 2001 Gentoo Technologies, Inc.; Distributed under the GPL"
64 echo
65
66 ebegin "Mounting /proc"
67 mount -n /proc
68 eend $?
69 devfs="yes"
70 for copt in `cat /proc/cmdline`
71 do
72 if [ "${copt%=*}" = "gentoo" ]
73 then
74 parms=${copt##*=}
75 #parse gentoo option
76 if [ "${parms/nodevfs//}" != "${parms}" ]
77 then
78 devfs="no"
79 fi
80 fi
81 done
82
83 if [ -e /dev/.devfsd ]
84 then
85 clear
86 echo
87 einfo "The Gentoo Linux system initialization scripts have detected that /dev"
88 einfo "has been automatically mounted by the kernel. This behavior will"
89 einfo "prevent devfs from automatically saving and restoring device"
90 einfo "permissions. While not optimal, your system will still be able to boot,"
91 einfo "but any changes to permissions in /dev will not be persistent until you"
92 einfo "fix this problem."
93 echo
94 einfo "Fortunately, the fix for this problem is quite simple; all you need to"
95 einfo "do is pass the \"devfs=nomount\" boot option to the kernel (via GRUB"
96 einfo "or LILO) the next time you boot. Then /dev will not be auto-mounted."
97 einfo "The next time you compile your kernel, be sure that you do not"
98 einfo "enable the \"Automatically mount filesystem at boot\" devfs kernel"
99 einfo "configuration option. Then the \"devfs=nomount\" hack will no longer be"
100 einfo "needed."
101 echo
102 read -t 15 -p "(hit Enter to continue or wait 15 seconds...)"
103 else
104 ebegin "Moving /dev to /dev-state"; try mount -n --bind /dev /dev-state; eend
105 ebegin "Mounting devfs at /dev"; try mount -n -t devfs none /dev; eend
106 if [ -d /dev-state/compat ]
107 then
108 ebegin "Copying devices from /dev-state/compat to /dev"
109 cp -ax /dev-state/compat/* /dev
110 eend
111 fi
112 fi
113
114 #mount shm and do dep scan
115 mountshm
116 /etc/init.d/depscan.sh
117
118 if [ "$devfs" = "yes" ]
119 then
120 ebegin "Starting devfsd"; /sbin/devfsd /dev >/dev/null 2>&1; eend $?
121 fi
122
123 #swap needs to be activated *after* devfs has been mounted and *after*
124 #devfsd has been started, so that the fstab can be properly parsed
125
126 ebegin "Activating swap"
127 swapon -a
128 eend
129
130 #Now that swap has been activated, we can calculate a reasonable size limit
131 #for /dev/shm so that it doesn't exhaust VM if filled.
132
133 exec /sbin/init.system $*
134 #rename to init.system

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20