| #!/bin/bash |
| |
| # This is the file containing the filesystem. You probably shouldn't change |
| # it since the kernel has this name hard-wired. |
| FSFILE=root_fs |
| |
| # Increase this if you add more stuff and 100 Meg isn't enough. |
| FSMEGS=100 |
| |
| # This is a temporary mount point which will be used to mount the new |
| # filesystem while it's being built. |
| MNTDIR=mnt |
| |
| # Change these if your distribution is located someplace else |
| CDDIR=/mnt/cdrom |
| RPMDIR=$CDDIR/RedHat/RPMS |
| |
| # These are to get bash off the ground. You probably shouldn't change them. |
| BASH_RPMS="filesystem- ldconfig- glibc- libtermcap- bash-" |
| |
| # These are all the others. Add new rpms to this list if you want more stuff |
| # in your filesystem. |
| REST="bdflush- fileutils- grep- mingetty- mount- net-tools- textutils- \ |
| shadow-utils- chkconfig- procps- sed- mktemp- vixie-cron- modutils- \ |
| e2fsprogs- logrotate- sysklogd- console-tools- gawk- initscripts- quota- \ |
| slang- pwdb- cracklib- cracklib-dicts- compat-glibc- glib- pam- \ |
| sh-utils- util-linux- SysVinit- tcp_wrappers- tcsh- gdbm- perl-5.00503- \ |
| netkit-base- telnet- ftp- wu-ftpd- indexhtml- zlib- lynx- findutils-" |
| |
| function rpm_file() |
| { |
| local name=$1 |
| set $RPMDIR/$1[-0-9.i]*.rpm |
| if [ $# -ne 1 ] |
| then |
| echo |
| echo Found too many rpms for $name 2>&1 |
| elif [ ! -f $1 ] |
| then |
| echo |
| echo Found no rpms for $name 2>&1 |
| fi |
| echo $1 |
| } |
| |
| echo Creating an empty file... |
| dd if=/dev/zero of=$FSFILE bs=$((1024 * 1024)) count=$FSMEGS || exit 1 |
| |
| echo Making a file system in it... |
| sudo mke2fs -F $FSFILE || exit 1 |
| |
| echo Mounting it on $MNTDIR |
| sudo mount -o loop $FSFILE $MNTDIR || exit 1 |
| cd $MNTDIR |
| |
| sudo mkdir -p var/lib/rpm/ || exit 1 |
| sudo mkdir -p var/tmp/ || exit 1 |
| |
| echo Forcibly installing the rpms that bash needs |
| |
| for rpm in $BASH_RPMS |
| do |
| rpm_file=`rpm_file $rpm` |
| echo Installing $rpm_file |
| sudo rpm -i --nodeps --root `pwd` $rpm_file |
| done |
| |
| echo Bash should now work |
| |
| sudo rpm -i --root `pwd` `rpm_file setup-` |
| |
| echo -n Making devices... |
| sudo mkdir dev |
| echo -n "pts " |
| sudo mkdir dev/pts |
| echo -n "null " |
| sudo mknod dev/null c 1 3 |
| echo -n "console " |
| sudo mknod dev/console c 5 1 |
| echo -n "fhd0 " |
| sudo mknod dev/fhd0 b 62 0 |
| echo -n "tty0 " |
| sudo mknod dev/tty0 c 4 0 |
| echo -n "cua0 " |
| sudo mknod dev/cua0 c 5 64 |
| echo -n "ptmx " |
| sudo mknod dev/ptmx c 5 2 |
| sudo chmod 666 dev/ptmx |
| echo ptys |
| for i in 0 1 2 3 4 5 6 7 8 9 |
| do |
| sudo mknod dev/ptyp$i c 2 $i |
| sudo mknod dev/ttyp$i c 3 $i |
| sudo chmod 666 dev/ptyp$i dev/ttyp$i |
| done |
| |
| echo Installing a couple of rpms for info |
| sudo rpm -i --root `pwd` `rpm_file info-` `rpm_file ncurses-` |
| |
| echo Here are all the rest |
| for rpm in $REST |
| do |
| file=`rpm_file $rpm` |
| echo $file |
| sudo rpm -i --root `pwd` $file |
| done |
| |
| echo Setting up /etc/inittab |
| sudo bash -c 'cat > etc/inittab' <<EOF |
| # |
| # inittab This file describes how the INIT process should set up |
| # the system in a certain run-level. |
| # |
| # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> |
| # Modified for RHS Linux by Marc Ewing and Donnie Barnes |
| # |
| |
| # Default runlevel. The runlevels used by RHS are: |
| # 0 - halt (Do NOT set initdefault to this) |
| # 1 - Single user mode |
| # 2 - Multiuser, without NFS (The same as 3, if you do not have networking) |
| # 3 - Full multiuser mode |
| # 4 - unused |
| # 5 - X11 |
| # 6 - reboot (Do NOT set initdefault to this) |
| # |
| id:3:initdefault: |
| |
| # System initialization. |
| si::sysinit:/etc/rc.d/rc.sysinit |
| |
| l0:0:wait:/etc/rc.d/rc 0 |
| l1:1:wait:/etc/rc.d/rc 1 |
| l2:2:wait:/etc/rc.d/rc 2 |
| l3:3:wait:/etc/rc.d/rc 3 |
| l4:4:wait:/etc/rc.d/rc 4 |
| l5:5:wait:/etc/rc.d/rc 5 |
| l6:6:wait:/etc/rc.d/rc 6 |
| |
| # Things to run in every runlevel. |
| ud::once:/sbin/update |
| |
| # Trap CTRL-ALT-DELETE |
| ca::ctrlaltdel:/sbin/shutdown -t3 -r now |
| |
| # When our UPS tells us power has failed, assume we have a few minutes |
| # of power left. Schedule a shutdown for 2 minutes from now. |
| # This does, of course, assume you have powerd installed and your |
| # UPS connected and working correctly. |
| pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" |
| |
| # If power was restored before the shutdown kicked in, cancel it. |
| pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" |
| |
| |
| # Run gettys in standard runlevels |
| 0:2345:respawn:/sbin/mingetty tty0 |
| c:2345:respawn:/sbin/mingetty cua0 |
| |
| # Run xdm in runlevel 5 |
| # xdm is now a separate service |
| x:5:respawn:/etc/X11/prefdm -nodaemon |
| EOF |
| |
| echo Setting up /etc/passwd |
| sudo bash -c 'cat > etc/passwd' <<EOF |
| root::0:0:root:/root:/bin/bash |
| user::1:1:user:/home/user:/bin/bash |
| EOF |
| |
| echo Setting up /etc/group |
| sudo bash -c 'cat > etc/group' <<EOF |
| root::0:root |
| user::1:user |
| utmp:x:16: |
| EOF |
| |
| echo Setting up etc/fstab |
| sudo bash -c 'cat > etc/fstab' <<EOF |
| /dev/fhd0 / ext2 defaults 1 1 |
| none /proc proc defaults |
| none /dev/pts devpts mode=0622 0 0 |
| EOF |
| |
| echo Setting up etc/sysconfig/keyboard |
| sudo bash -c 'cat > etc/sysconfig/keyboard' <<EOF |
| KEYTABLE=us |
| EOF |
| |
| echo Setting up etc/securetty |
| sudo bash -c 'cat >> etc/securetty' <<EOF |
| cua0 |
| tty0 |
| EOF |
| |
| echo Setting up etc/issue |
| sudo bash -c 'cat > etc/issue' <<EOF |
| Welcome to the user-mode kernel. |
| EOF |
| |
| echo Copying /bin/true over /sbin/hwclock |
| sudo cp bin/true sbin/hwclock |
| |
| echo Setting up etc/pam.d so you can log in |
| sudo rm etc/pam.d/* |
| sudo bash -c 'cat > etc/pam.d/other' <<EOF |
| #%PAM-1.0 |
| auth required pam_unix_auth.so |
| account required pam_unix_acct.so |
| password required pam_unix_passwd.so |
| session required pam_unix_session.so |
| EOF |
| |
| sudo bash -c 'cat > etc/pam.d/ftp' <<EOF |
| #%PAM-1.0 |
| auth required pam_unix_auth.so |
| account required pam_unix_acct.so |
| password required pam_unix_passwd.so |
| session required pam_unix_session.so |
| EOF |
| |
| echo Setting up /etc/sysconfig/network |
| sudo bash -c 'cat > etc/sysconfig/network' <<EOF |
| NETWORKING=yes |
| FORWARD_IPV4=false |
| HOSTNAME=uml |
| EOF |
| |
| echo Setting up /etc/sysconfig/network-scripts/ifcfg-umn |
| sudo bash -c 'cat > etc/sysconfig/network-scripts/ifcfg-umn' <<EOF |
| DEVICE=umn |
| IPADDR=192.168.0.253 |
| NETMASK=255.255.255.0 |
| NETWORK=192.168.0.0 |
| BROADCAST=192.168.0.255 |
| ONBOOT=yes |
| EOF |
| |
| echo Setting up /etc/sysconfig/network-scripts/ifup-umn |
| sudo bash -c 'cat > etc/sysconfig/network-scripts/ifup-umn' <<EOF |
| #!/bin/bash |
| cd /etc/sysconfig/network-scripts |
| . network-functions |
| |
| CONFIG=\$1 |
| source_config |
| |
| if [ "\$2" != "boot" ] |
| then |
| exit 0 |
| fi |
| |
| ether="" |
| |
| for n in \`echo \$IPADDR | sed 's/\./ /g'\` |
| do |
| ether="\$ether\`echo \$n | awk '{printf "%x", \$0}'\`:" |
| done |
| |
| ether="\$ether"0:0 |
| |
| ifconfig \$DEVICE \$IPADDR hw ether \$ether |
| |
| exit 0 |
| EOF |
| |
| sudo chmod 755 etc/sysconfig/network-scripts/ifup-umn |
| |
| cd .. |
| sudo umount $MNTDIR || exit 1 |
| |
| echo All set |