s243a

mount_rootfs - Stripping a puppy

Mar 21st, 2019
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.15 KB | None | 0 0
  1. #!/bin/sh
  2. curdir=`pwd`
  3. rootfs="root_fs"
  4. xinteractive =1
  5. unmount_vfs(){
  6.  umount -l $curdir/$rootfs/dev 2>/dev/null
  7.  umount -l $curdir/$rootfs/sys 2>/dev/null
  8.  umount -l $curdir/$rootfs/proc 2>/dev/null
  9.  #umount /mnt/wktaz 2>/dev/null
  10.  #umount /mnt/wksfs 2>/dev/null
  11. }  
  12.  
  13. trap unmount_vfs EXIT
  14. trap unmount_vfs SIGKILL
  15. trap unmount_vfs SIGTERM
  16. xinteractive=1
  17. echo "PUPMODE='2'" > $curdir/$rootfs$prefix/etc/rc.d/PUPSTATE
  18. mkdir -p $curdir/$rootfs/proc;
  19. mkdir -p $curdir/$rootfs/sys
  20.  
  21. mount -o rbind /proc $curdir/$rootfs/proc
  22. mount -t sysfs none $curdir/$rootfs/sys
  23. if [ $xinteractive -eq 1 ]; then
  24.  echo "Removing block device files..."
  25.  #rm -rf $curdir/$rootfs/dev/*
  26.  #mount bind -t devtmpfs none $curdir/$rootfs/dev
  27.  mount -o rbind /dev $curdir/$rootfs/dev
  28.  cp -f /etc/resolv.conf $curdir/$rootfs/etc/resolv.conf
  29. fi
  30.  
  31. chroot $curdir/$rootfs /bin/ash
  32.  
  33.  
  34. if [ "$(mount | grep "$curdir/$rootfs/dev")" != "" ]; then
  35.  umount -l $curdir/$rootfs/dev
  36. fi 
  37.  
  38. if [ "$(mount | grep "$curdir/$rootfs/sys")" != "" ]; then
  39.  umount -l $curdir/$rootfs/sys
  40. fi 
  41. if [ "$(mount | grep "$curdir$rootfs/proc")" != "" ]; then
  42.  umount -l $curdir/$rootfs/proc
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment