home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1999 November / VPR9911B.ISO / misc / src / trees / updrescue < prev    next >
Text File  |  1999-04-07  |  3KB  |  122 lines

  1. #!/bin/sh
  2.  
  3. LIBS="libc libext2fs.so libuuid libnss_files libe2p libtermcap libcom_err
  4.       libnsl libnss_files libnss_dns libproc"
  5. USRLIBS=""
  6. BINS="bzip2 ls mke2fs bash open fdisk badblocks rm chmod cat lsmod
  7.       mkdir mknod mount rm umount ln cpio rpm tar cp ifconfig route
  8.       e2fsck grep sed gzip dd cpio mt mv ping traceroute sync chroot restore
  9.       head tail swapon rpm ps tac pico vim df"
  10. DEVS="hda hdb hdc hdd sda sdb sdc sde sdf sdg scd tty1 tty2 console ram null 
  11.       systty zero fd"
  12. USRLIB="rpm/rpmrc rpm/rpmpopt rpm/macros"
  13. ETC="services protocols"
  14.  
  15. usage () {
  16.     echo "updrescue takes no parameters" 2>&1
  17.     exit 1
  18. }
  19.  
  20. if [ -n "$1" ]; then
  21.     usage
  22. fi
  23.  
  24. rm -rf rescue
  25. mkdir -p rescue/lib         rescue/usr         rescue/bin     \
  26.      rescue/etc         rescue/usr/lib         rescue/mnt     \
  27.      rescue/mnt/image    rescue/dev         rescue/tmp     \
  28.      rescue/mnt/floppy    rescue/mkdir        rescue/proc
  29. ln -s bin rescue/sbin
  30. ln -s ../bin rescue/usr/bin
  31. ln -s ../bin rescue/usr/sbin
  32. ln -s gzip rescue/bin/gunzip
  33. ln -s swapon rescue/bin/swapoff
  34. ln -s bash rescue/bin/sh
  35.  
  36. cp -a /lib/ld-2*.so rescue/lib
  37. cp -a /lib/ld-linux.so.2* rescue/lib
  38.  
  39.  
  40. for n in $ETC; do
  41.     cp -a /etc/$n rescue/etc
  42. done
  43.  
  44. echo "Copying libraries"
  45.  
  46. for n in $LIBS; do
  47.     # this preserves hard links
  48.     (cd /lib; tar cSpf - ${n}[-.]*) | (cd rescue/lib; tar xSpf -)
  49. done
  50.  
  51. for n in $USRLIBS; do
  52.     # this preserves hard links
  53.     (cd /usr/lib; tar cSpf - ${n}[-.]*) | (cd rescue/lib; tar xSpf -)
  54. done
  55.  
  56. echo "Stripping libraries"
  57. (cd rescue/lib; file * | grep 'shared object' | cut -d: -f1 | xargs strip)
  58.  
  59. echo "Copying binaries"
  60.  
  61. for n in $BINS; do
  62.     rm -f supp/usr/bin/$n
  63.     cp -af `which $n` rescue/bin
  64. done
  65.  
  66. echo "Copying devices"
  67.  
  68. for n in $DEVS; do
  69.     for d in /dev/${n}*; do
  70.         cp -af $d rescue/dev
  71.     done
  72. done
  73.  
  74. for n in $USRLIB; do
  75.     cp -af /usr/lib/$n rescue/usr/lib
  76. done
  77.  
  78. cat >> rescue/etc/fstab <<EOF
  79. /dev/ram    /        ext2    defaults
  80. /proc        /proc        proc    defaults
  81. /dev/fd0    /mnt/floppy    ext2    defaults
  82. EOF
  83.  
  84. touch rescue/etc/mtab
  85.  
  86. cat >> rescue/sbin/init <<EOF
  87. #!/bin/sh
  88.  
  89. mount -n -o remount,rw /
  90. mount /proc
  91. cp /proc/mounts /etc/mtab
  92.  
  93. open -l /bin/sh
  94.  
  95. echo ''
  96. echo 'This is the Red Hat rescue disk. Most of the basic system commands are'
  97. echo 'in /bin.'
  98. echo ''
  99. echo 'Type exit to halt the system.'
  100. echo ''
  101.  
  102. /bin/sh
  103.  
  104. echo "Unmounting filesystems..."
  105. tac /proc/mounts | while read line ; do
  106.     set $line
  107.     if [ $2 != "/" ]; then
  108.     umount $1
  109.     fi
  110. done
  111. echo "Halting system.. All fixed? :-)"
  112. EOF
  113.  
  114. chmod +x rescue/sbin/init
  115.  
  116. mkdir -p rescue/usr/share/terminfo/l
  117. cp /usr/share/terminfo/l/linux rescue/usr/share/terminfo/l
  118.  
  119. infocmp linux > foo
  120. infotocap -C foo > rescue/etc/termcap
  121. rm -f foo
  122.