Version:
~ [ 0.6-2.3.46 ] ~
Architecture:
~ [ um ] ~
1 #!/bin/bash
2
3 # This is the file containing the filesystem. You probably shouldn't change
4 # it since the kernel has this name hard-wired.
5 FSFILE=root_fs
6
7 # Increase this if you add more stuff and 100 Meg isn't enough.
8 FSMEGS=100
9
10 # This is a temporary mount point which will be used to mount the new
11 # filesystem while it's being built.
12 MNTDIR=mnt
13
14 # Change these if your distribution is located someplace else
15 CDDIR=/mnt/cdrom
16 RPMDIR=$CDDIR/RedHat/RPMS
17
18 # These are to get bash off the ground. You probably shouldn't change them.
19 BASH_RPMS="filesystem- ldconfig- glibc- libtermcap- bash-"
20
21 # These are all the others. Add new rpms to this list if you want more stuff
22 # in your filesystem.
23 REST="bdflush- fileutils- grep- mingetty- mount- net-tools- textutils- \
24 shadow-utils- chkconfig- procps- sed- mktemp- vixie-cron- modutils- \
25 e2fsprogs- logrotate- sysklogd- console-tools- gawk- initscripts- quota- \
26 slang- pwdb- cracklib- cracklib-dicts- compat-glibc- glib- pam- \
27 sh-utils- util-linux- SysVinit- tcp_wrappers- tcsh- gdbm- perl-5.00503- \
28 netkit-base- telnet- ftp- wu-ftpd- indexhtml- zlib- lynx- findutils-"
29
30 function rpm_file()
31 {
32 local name=$1
33 set $RPMDIR/$1[-0-9.i]*.rpm
34 if [ $# -ne 1 ]
35 then
36 echo
37 echo Found too many rpms for $name 2>&1
38 elif [ ! -f $1 ]
39 then
40 echo
41 echo Found no rpms for $name 2>&1
42 fi
43 echo $1
44 }
45
46 echo Creating an empty file...
47 dd if=/dev/zero of=$FSFILE bs=$((1024 * 1024)) count=$FSMEGS || exit 1
48
49 echo Making a file system in it...
50 sudo mke2fs -F $FSFILE || exit 1
51
52 echo Mounting it on $MNTDIR
53 sudo mount -o loop $FSFILE $MNTDIR || exit 1
54 cd $MNTDIR
55
56 sudo mkdir -p var/lib/rpm/ || exit 1
57 sudo mkdir -p var/tmp/ || exit 1
58
59 echo Forcibly installing the rpms that bash needs
60
61 for rpm in $BASH_RPMS
62 do
63 rpm_file=`rpm_file $rpm`
64 echo Installing $rpm_file
65 sudo rpm -i --nodeps --root `pwd` $rpm_file
66 done
67
68 echo Bash should now work
69
70 sudo rpm -i --root `pwd` `rpm_file setup-`
71
72 echo -n Making devices...
73 sudo mkdir dev
74 echo -n "pts "
75 sudo mkdir dev/pts
76 echo -n "null "
77 sudo mknod dev/null c 1 3
78 echo -n "console "
79 sudo mknod dev/console c 5 1
80 echo -n "fhd0 "
81 sudo mknod dev/fhd0 b 62 0
82 echo -n "tty0 "
83 sudo mknod dev/tty0 c 4 0
84 echo -n "cua0 "
85 sudo mknod dev/cua0 c 5 64
86 echo -n "ptmx "
87 sudo mknod dev/ptmx c 5 2
88 sudo chmod 666 dev/ptmx
89 echo ptys
90 for i in 0 1 2 3 4 5 6 7 8 9
91 do
92 sudo mknod dev/ptyp$i c 2 $i
93 sudo mknod dev/ttyp$i c 3 $i
94 sudo chmod 666 dev/ptyp$i dev/ttyp$i
95 done
96
97 echo Installing a couple of rpms for info
98 sudo rpm -i --root `pwd` `rpm_file info-` `rpm_file ncurses-`
99
100 echo Here are all the rest
101 for rpm in $REST
102 do
103 file=`rpm_file $rpm`
104 echo $file
105 sudo rpm -i --root `pwd` $file
106 done
107
108 echo Setting up /etc/inittab
109 sudo bash -c 'cat > etc/inittab' <<EOF
110 #
111 # inittab This file describes how the INIT process should set up
112 # the system in a certain run-level.
113 #
114 # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
115 # Modified for RHS Linux by Marc Ewing and Donnie Barnes
116 #
117
118 # Default runlevel. The runlevels used by RHS are:
119 # 0 - halt (Do NOT set initdefault to this)
120 # 1 - Single user mode
121 # 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
122 # 3 - Full multiuser mode
123 # 4 - unused
124 # 5 - X11
125 # 6 - reboot (Do NOT set initdefault to this)
126 #
127 id:3:initdefault:
128
129 # System initialization.
130 si::sysinit:/etc/rc.d/rc.sysinit
131
132 l0:0:wait:/etc/rc.d/rc 0
133 l1:1:wait:/etc/rc.d/rc 1
134 l2:2:wait:/etc/rc.d/rc 2
135 l3:3:wait:/etc/rc.d/rc 3
136 l4:4:wait:/etc/rc.d/rc 4
137 l5:5:wait:/etc/rc.d/rc 5
138 l6:6:wait:/etc/rc.d/rc 6
139
140 # Things to run in every runlevel.
141 ud::once:/sbin/update
142
143 # Trap CTRL-ALT-DELETE
144 ca::ctrlaltdel:/sbin/shutdown -t3 -r now
145
146 # When our UPS tells us power has failed, assume we have a few minutes
147 # of power left. Schedule a shutdown for 2 minutes from now.
148 # This does, of course, assume you have powerd installed and your
149 # UPS connected and working correctly.
150 pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
151
152 # If power was restored before the shutdown kicked in, cancel it.
153 pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
154
155
156 # Run gettys in standard runlevels
157 0:2345:respawn:/sbin/mingetty tty0
158 c:2345:respawn:/sbin/mingetty cua0
159
160 # Run xdm in runlevel 5
161 # xdm is now a separate service
162 x:5:respawn:/etc/X11/prefdm -nodaemon
163 EOF
164
165 echo Setting up /etc/passwd
166 sudo bash -c 'cat > etc/passwd' <<EOF
167 root::0:0:root:/root:/bin/bash
168 user::1:1:user:/home/user:/bin/bash
169 EOF
170
171 echo Setting up /etc/group
172 sudo bash -c 'cat > etc/group' <<EOF
173 root::0:root
174 user::1:user
175 utmp:x:16:
176 EOF
177
178 echo Setting up etc/fstab
179 sudo bash -c 'cat > etc/fstab' <<EOF
180 /dev/fhd0 / ext2 defaults 1 1
181 none /proc proc defaults
182 none /dev/pts devpts mode=0622 0 0
183 EOF
184
185 echo Setting up etc/sysconfig/keyboard
186 sudo bash -c 'cat > etc/sysconfig/keyboard' <<EOF
187 KEYTABLE=us
188 EOF
189
190 echo Setting up etc/securetty
191 sudo bash -c 'cat >> etc/securetty' <<EOF
192 cua0
193 tty0
194 EOF
195
196 echo Setting up etc/issue
197 sudo bash -c 'cat > etc/issue' <<EOF
198 Welcome to the user-mode kernel.
199 EOF
200
201 echo Copying /bin/true over /sbin/hwclock
202 sudo cp bin/true sbin/hwclock
203
204 echo Setting up etc/pam.d so you can log in
205 sudo rm etc/pam.d/*
206 sudo bash -c 'cat > etc/pam.d/other' <<EOF
207 #%PAM-1.0
208 auth required pam_unix_auth.so
209 account required pam_unix_acct.so
210 password required pam_unix_passwd.so
211 session required pam_unix_session.so
212 EOF
213
214 sudo bash -c 'cat > etc/pam.d/ftp' <<EOF
215 #%PAM-1.0
216 auth required pam_unix_auth.so
217 account required pam_unix_acct.so
218 password required pam_unix_passwd.so
219 session required pam_unix_session.so
220 EOF
221
222 echo Setting up /etc/sysconfig/network
223 sudo bash -c 'cat > etc/sysconfig/network' <<EOF
224 NETWORKING=yes
225 FORWARD_IPV4=false
226 HOSTNAME=uml
227 EOF
228
229 echo Setting up /etc/sysconfig/network-scripts/ifcfg-umn
230 sudo bash -c 'cat > etc/sysconfig/network-scripts/ifcfg-umn' <<EOF
231 DEVICE=umn
232 IPADDR=192.168.0.253
233 NETMASK=255.255.255.0
234 NETWORK=192.168.0.0
235 BROADCAST=192.168.0.255
236 ONBOOT=yes
237 EOF
238
239 echo Setting up /etc/sysconfig/network-scripts/ifup-umn
240 sudo bash -c 'cat > etc/sysconfig/network-scripts/ifup-umn' <<EOF
241 #!/bin/bash
242 cd /etc/sysconfig/network-scripts
243 . network-functions
244
245 CONFIG=\$1
246 source_config
247
248 if [ "\$2" != "boot" ]
249 then
250 exit 0
251 fi
252
253 ether=""
254
255 for n in \`echo \$IPADDR | sed 's/\./ /g'\`
256 do
257 ether="\$ether\`echo \$n | awk '{printf "%x", \$0}'\`:"
258 done
259
260 ether="\$ether"0:0
261
262 ifconfig \$DEVICE \$IPADDR hw ether \$ether
263
264 exit 0
265 EOF
266
267 sudo chmod 755 etc/sysconfig/network-scripts/ifup-umn
268
269 cd ..
270 sudo umount $MNTDIR || exit 1
271
272 echo All set
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.