[22901] | 1 | #!/bin/sh |
---|
| 2 | set -e |
---|
| 3 | |
---|
| 4 | sysimage=/srv/chroot/athena |
---|
| 5 | |
---|
| 6 | export SYSTEM=/afs/athena.mit.edu/system/rhlinux |
---|
| 7 | export CONTROL=control/control-current |
---|
| 8 | export IPADDR=127.0.0.1 |
---|
| 9 | |
---|
| 10 | tmpdir=$(mktemp -td) |
---|
| 11 | chroot="$tmpdir/chroot" |
---|
| 12 | |
---|
| 13 | maybe_umount () |
---|
| 14 | { |
---|
| 15 | grep -q "^[^ ]* $1 " /proc/mounts || return 0 |
---|
| 16 | umount "$@" |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | maybe_umount "$chroot/sysimage/proc" |
---|
| 20 | maybe_umount "$chroot/sysimage" |
---|
| 21 | maybe_umount "$chroot/mnt/runtime" |
---|
| 22 | maybe_umount "$chroot/tmp/ramfs" |
---|
| 23 | maybe_umount "$chroot/tmp" |
---|
| 24 | maybe_umount "$chroot/dev/pts" |
---|
| 25 | maybe_umount "$chroot/proc" |
---|
| 26 | maybe_umount "$chroot/sys" |
---|
| 27 | maybe_umount "$chroot/afs" |
---|
| 28 | maybe_umount "$chroot" |
---|
| 29 | |
---|
| 30 | rm -rf "$tmpdir" |
---|
| 31 | mkdir -p "$tmpdir" |
---|
| 32 | |
---|
| 33 | mcopy -i /mit/bootkit/rhlinux/athena.img ::/initrd.img "$tmpdir/initrd.img.gz" |
---|
| 34 | gunzip "$tmpdir/initrd.img.gz" |
---|
| 35 | mkdir "$chroot" |
---|
| 36 | mount -t ext2 -o rw,loop "$tmpdir/initrd.img" "$chroot" |
---|
| 37 | |
---|
| 38 | mount -t ramfs none "$chroot/tmp" |
---|
| 39 | mkdir "$chroot/tmp/ramfs" |
---|
| 40 | mount -t ramfs none "$chroot/tmp/ramfs" |
---|
| 41 | wget -N http://tae-kwon-leap.mit.edu/linux/rhlinux5a.img -O "$chroot/tmp/ramfs/rhlinux5a.img" |
---|
| 42 | mkdir -p "$chroot/mnt/runtime" |
---|
| 43 | mount -t cramfs -o ro,loop "$chroot/tmp/ramfs/rhlinux5a.img" "$chroot/mnt/runtime" |
---|
| 44 | |
---|
| 45 | mount -t proc proc "$chroot/proc" |
---|
| 46 | mount -t devpts devpts "$chroot/dev/pts" |
---|
| 47 | |
---|
| 48 | ln -s mnt/runtime/lib mnt/runtime/usr "$chroot/" |
---|
| 49 | mkdir "$chroot/afs" |
---|
| 50 | mount --bind /afs "$chroot/afs" |
---|
| 51 | |
---|
| 52 | mkdir -p "$sysimage" |
---|
| 53 | mkdir "$chroot/sysimage" |
---|
| 54 | mount --bind "$sysimage" "$chroot/sysimage" |
---|
| 55 | |
---|
| 56 | mkdir -p "$chroot/sys" |
---|
| 57 | mount -t sysfs sysfs "$chroot/sys" |
---|
| 58 | mkdir -p "$sysimage/etc" "$chroot/etc" |
---|
| 59 | cp -a /etc/fstab "$chroot/etc" |
---|
| 60 | cp -a /etc/fstab "$sysimage/etc" |
---|
| 61 | |
---|
| 62 | cp -a /usr/share/debathena-athena-chroot/installer/phase2.debathena "$chroot" |
---|
| 63 | cp -a /usr/share/debathena-athena-chroot/installer/phase2.backend.debathena "$chroot" |
---|
| 64 | chroot "$chroot" /phase2.debathena |
---|
| 65 | mkdir -p "$sysimage/dev/pts" |
---|
| 66 | mkdir -p "$sysimage/dev/shm" |
---|
[22908] | 67 | # setup Athena machine to use NSS for naming information |
---|
| 68 | # This code currently is an awful hack that assumes a 32-bit host. |
---|
| 69 | cp -a /etc/hesiod.conf "$sysimage/etc" |
---|
| 70 | cp -a /etc/nsswitch.conf.debathena "$sysimage/etc/nsswitch.conf" |
---|
| 71 | cp -a /lib/libnss_nonlocal* "$sysimage/lib" |
---|
| 72 | cp -a /lib/libnss_afspag* "$sysimage/lib" |
---|
[22901] | 73 | |
---|
| 74 | maybe_umount "$chroot/sysimage/proc" |
---|
| 75 | maybe_umount "$chroot/sysimage" |
---|
| 76 | maybe_umount "$chroot/mnt/runtime" |
---|
| 77 | maybe_umount "$chroot/tmp/ramfs" |
---|
| 78 | maybe_umount "$chroot/tmp" |
---|
| 79 | maybe_umount "$chroot/dev/pts" |
---|
| 80 | maybe_umount "$chroot/proc" |
---|
| 81 | maybe_umount "$chroot/sys" |
---|
| 82 | maybe_umount "$chroot/afs" |
---|
| 83 | maybe_umount "$chroot" |
---|