|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#######
#
# E-scripts on running chrooted systems with a "float" partition
# being shared by all of them
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
# (find-eev-quick-intro)
# http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/float.e>
# or at <http://angg.twu.net/e/float.e.html>.
# See also <http://angg.twu.net/emacs.html>,
# <http://angg.twu.net/.emacs[.html]>,
# <http://angg.twu.net/.zshrc[.html]>,
# <http://angg.twu.net/escripts.html>,
# and <http://angg.twu.net/>.
#
#######
# (find-es "debian-cd")
# (find-eevfile "demo/debian.e")
# «.rescue.bin» (to "rescue.bin")
# «.rescue.bin_scripts» (to "rescue.bin_scripts")
# «.ln-sf-safe» (to "ln-sf-safe")
# «.inittab» (to "inittab")
# «.inittab-chroots» (to "inittab-chroots")
# «.fstab» (to "fstab")
#####
#
# Examine the 2.88MB rescue floppy
#
#####
# «rescue.bin» (to ".rescue.bin")
# (find-k22file "Documentation/Configure.help" "CONFIG_BLK_DEV_LOOP")
#*
umount proc_rescue
umount /tmp/rescue/
umount /tmp/rescuefs/
rm -Rv /tmp/rescue/
rm -Rv /tmp/rescuefs/
#:*
mkdir /tmp/rescue/
mkdir /tmp/rescuefs/
cp -v /var/_potato1/rescue.bin /tmp/rescue.bin
cp -v /var/_potato1/rescue.bin /tmp/rescue.bin.orig
mount /tmp/rescue.bin /tmp/rescue -t msdos -o loop
zcat /tmp/rescue/root.bin > /tmp/root.bin.ext2
zcat /tmp/rescue/root.bin > /tmp/root.bin.ext2.orig
mount /tmp/root.bin.ext2 /tmp/rescuefs/ -t ext2 -o loop
mount proc_rescue /tmp/rescuefs/proc -t proc
# (eeman "8 mount" "proc")
# (find-fline "/tmp/rescue/")
# (find-fline "/tmp/rescue/syslinux.cfg" "initrd=root.bin")
# (find-fline "/tmp/rescuefs/")
#*
# A way to chroot to the shell that the rescue floppy sets at VT 2...
# (find-fline "/tmp/rescuefs/bin/")
# (find-fline "/tmp/rescuefs/etc/")
# (find-fline "/tmp/rescuefs/etc/inittab")
chroot /tmp/rescuefs/ /bin/sh
#*
# A way to chroot to dbootstrap, that the rescue floppy sets as VT 1.
expect -c '
spawn chroot /tmp/rescuefs/ /sbin/dbootstrap
interact -re "\0361|\033q" { exec kill [exp_pid] }
'
#*
#####
#
# Creating another rescue.bin with some extra scripts
#
#####
# «rescue.bin_scripts» (to ".rescue.bin_scripts")
#*
cd /tmp/rescuefs/bin/
cat > monta_cd <<'---'
#!/bin/sh
echo Tentando montar o CD em /instmnt...
echo mount -t iso9660 -o ro /instmnt /dev/hda
mount -t iso9660 -o ro /instmnt /dev/hda
echo mount -t iso9660 -o ro /instmnt /dev/hdb
mount -t iso9660 -o ro /instmnt /dev/hdb
echo mount -t iso9660 -o ro /instmnt /dev/hdc
mount -t iso9660 -o ro /instmnt /dev/hdc
echo mount -t iso9660 -o ro /instmnt /dev/hdd
mount -t iso9660 -o ro /instmnt /dev/hdd
echo 'mount | grep iso9660'
mount | grep iso9660
---
chmod 755 monta_cd
#:*
cd /tmp/rescuefs/bin/
cat > copia_tgz <<'---'
#!/bin/sh
echo Copiando o .tgz do CD para o HD...
echo cp /instmnt/CIPSGAescolar.tgz /target/CIPSGAescolar.tgz
cp /instmnt/CIPSGAescolar.tgz /target/CIPSGAescolar.tgz
echo ls -l /target/01jul25.tgz
ls -l /target/01jul25.tgz
---
chmod 755 copia_tgz
#:*
# (find-fline "/tmp/rescuefs/sbin/MAKEDEV")
# (find-node "(bash)Bash Conditional Expressions")
# (eeman "1 grep" "exit status is 0")
cd /tmp/rescuefs/bin/
cat > descompacta_em <<'---'
#!/bin/ash
if [ -e /target/CIPSGAescolar.tgz ]; then
TGZ=/target/CIPSGAescolar.tgz; echo Usando o arquivo $TGZ...
elif [ -e /instmnt/CIPSGAescolar.tgz ]; then
TGZ=/instmnt/CIPSGAescolar.tgz; echo Usando o arquivo $TGZ...
else
echo "Erro: nem /target/CIPSGAescolar.tgz"
echo " nem /instmnt/CIPSGAescolar.tgz foram encontrados"
exit 1
fi
echo Descompactando $TGZ em $1...
echo "zcat $TGZ | tar -xvf - -C $1"
zcat $TGZ | tar -xvf - -C $1
---
chmod 755 descompacta_em
#:*
cd /tmp/
umount proc_rescue
umount /tmp/rescuefs/
gzip -c9 < /tmp/root.bin.ext2 > /tmp/root.bin
ls -l /tmp/root2.bin /tmp/rescue/root.bin
md5sum /tmp/rescue.bin
cp -v /tmp/root.bin /tmp/rescue/root.bin
mount | grep rescue
umount /tmp/rescue
md5sum /tmp/rescue.bin
#*
#####
#
# ln-sf-safe
# 2004mar07
#
#####
# «ln-sf-safe» (to ".ln-sf-safe")
# (find-angg ".zshrc" "ln-sf-safe")
#*
laf -d \
/mnt \
/mnt-local \
/newdebian \
/newdebian/mnt \
/newdebian/mnt-local
#*
# (find-man "ln")
# (find-node "(zsh)Conditional Expressions")
function ln-sf-safe () {
if [[ -h $2 ]]; then rm -v $2; fi
if [[ ! -a $2 ]]; then
ln -s $1 $2
else
echo "Not a symlink: $2"; false
fi
}
ln-sf-safe newdebian/mnt /mnt
ln-sf-safe mnt-local /newdebian/mnt
ln-sf-safe mnt/float /hdb2
ln-sf-safe mnt/float /newdebian/hdb2
ln-sf-safe mnt/float /float
ln-sf-safe mnt/float /newdebian/float
ln-sf-safe float/CDs /CDs
ln-sf-safe float/CDs /newdebian/CDs
#*
laf /newdebian/mnt-local
laf /mnt-local
#*
mount /hdb2
mount /mnt/woodybin1
mount /mnt/woodybin2
mount /mnt/woodybin3
mount /mnt/woodybin4
#*
#*
cd /
( find * -maxdepth 0 -type l
find mnt-local/* newdebian/mnt-local/* -maxdepth 0 -type l -or -type d
print -l CDs/woody CDs/woody/*
) | sort | tee ~/o
for i in $(<~/o); do
if [[ -h $i ]]; then
echo ln-sf-safe $(readlink $i) $i
elif [[ -d $i ]]; then
echo mkdir $i
fi
done
#*
for i in $(<~/o); do
if [[ -h $i ]]; then
echo $i '->' $(readlink $i)
elif [[ -d $i ]]; then
echo $i/
fi
done
#*
cd /CDs/woody/
ln-sf-safe ../jigdo/debian-30r2-i386-binary-1_NONUS.iso bin1.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-2.iso bin2.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-3.iso bin3.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-4.iso bin4.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-5.iso bin5.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-6.iso bin6.iso
ln-sf-safe ../jigdo/debian-30r2-i386-binary-7.iso bin7.iso
mount /mnt/woodybin5
mount /mnt/woodybin6
mount /mnt/woodybin7
cd /mnt/woodybin5
#*
cd /mnt/woodybin6
md5sum -v -c md5sum.txt
#*
cd /mnt/woodybin7
md5sum -v -c md5sum.txt
#*
####
#
# /etc/inittab
# 2004mar09
#
####
# «inittab» (to ".inittab")
# (find-fline "/etc/inittab")
# (find-fline "/etc/inittab" "6:23:respawn:/sbin/getty 38400 tty6")
#
# (find-es "float" "inittab")
#7:23:respawn:/sbin/getty 38400 tty7
8:23:respawn:/sbin/getty 38400 tty8
9:23:respawn:/sbin/getty 38400 tty9
10:23:respawn:/sbin/getty 38400 tty10
11:23:respawn:/sbin/getty 38400 tty11
12:23:respawn:/sbin/getty 38400 tty12
# «inittab-chroots» (to ".inittab-chroots")
# (find-fline "/etc/inittab")
# (find-fline "/etc/rcS.d")
# (find-fline "/etc/rc2.d")
# (find-fline "/etc/rc2.d/S99rmnologin")
# (find-man "telinit")
# (eev "telinit q")
11:23:respawn:/usr/sbin/chroot /newdebian /sbin/getty 38400 tty11
12:23:respawn:/usr/sbin/chroot /newdebian /sbin/getty 38400 tty12
I have debian in two partitions here, / and /newdebian - to run things
cleanly on /newdebian do I just need the inittab trick,
"11:23:respawn:/usr/sbin/chroot /newdebian /sbin/getty 38400 tty11"?
Or should I also fake something like "/etc/init.d/rc 2"?
#*
ps auwx | l -S
#*
Other things:
/dev/gpmdata must be shared
/etc/resolv.conf must be copied (?) to the subpartitions
####
#
# /etc/fstab
# 2004mar07
#
####
# «fstab» (to ".fstab")
proc2 /newdebian/proc proc defaults 0 0
# (eev "for i in /mnt/woodybin{1,2,3,4,5,6,7}; do echo $i; mount $i; done")
#
/CDs/woody/bin1.iso /mnt/woodybin1 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin2.iso /mnt/woodybin2 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin3.iso /mnt/woodybin3 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin4.iso /mnt/woodybin4 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin5.iso /mnt/woodybin5 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin6.iso /mnt/woodybin6 iso9660 defaults,ro,loop,user,noauto 0 0
/CDs/woody/bin7.iso /mnt/woodybin7 iso9660 defaults,ro,loop,user,noauto 0 0
# (find-fline "/mnt/woodybin1/install/")
# (eev "zcat /mnt/woodybin1/install/bf24.bin > /tmp/bf24.fs")
# (eev "zcat /mnt/woodybin1/install/compact.bin > /tmp/compact.fs")
# (eev "zcat /mnt/woodybin1/install/idepci.bin > /tmp/idepci.fs")
# (eev "zcat /mnt/woodybin1/install/root.bin > /tmp/root.fs")
#
# (find-fline "/mnt/woodybin1/install/" "sbm.bin")
# (find-fline "/mnt/woodybin1/install/README.sbm")
# Don't try to mount sbm.bin, it's just a "Smart Boot Manager".
#
/tmp/bf24.fs /mnt/bf24 ext2 defaults,loop,noauto 0 0
/tmp/compact.fs /mnt/compact ext2 defaults,loop,noauto 0 0
/tmp/idepci.fs /mnt/idepci ext2 defaults,loop,noauto 0 0
/tmp/root.fs /mnt/root ext2 defaults,loop,noauto 0 0
#
/mnt/woodybin1/install/rescue.bin /mnt/rescue msdos defaults,ro,loop,noauto 0 0
####
#
# /etc/passwd
# 2004mar09
#
####
# (find-fline "/etc/passwd")
# (find-fline "/etc/group")
# (find-man "5 passwd")
ochs::0:0:Eduardo Ochs,,,:/home/edrx:/usr/bin/zsh
edrx::1000:1000:Eduardo Ochs,,,:/home/edrx:/usr/bin/zsh
# (find-status "getty")
# (find-vldifile "getty.list")
# (find-fline "/usr/doc/getty/")
# Local Variables:
# coding: utf-8-unix
# End: