decimusphostle

debian postinst

Mar 27th, 2013
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.20 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #Assumes installation to /path/to/chroot
  4. chroot_location=/path/to/chroot
  5.  
  6. # set -e #Commenting this out for now as mount returns non-zero
  7.          #due to a remount of /sys
  8. set -x
  9.  
  10. if [ "$1" = "configure" ];
  11. then
  12.     lenny_chroot_suffix=.lenny_chroot.old
  13.  
  14.     #Setup schroot.conf
  15.     new_schroot_conf_file=/tmp/schroot.conf
  16.     cat <<SCHROOT > $new_schroot_conf_file
  17.  
  18. [lenny]
  19. description=Debian lenny for amd64
  20. aliases=debian_lenny_amd64
  21. location=$chroot_location
  22. root-users=root
  23. type=plain
  24. users=root
  25. groups=root
  26. SCHROOT
  27.     schroot_conf_file=/etc/schroot/schroot.conf
  28.     archived_schroot_conf_file="${schroot_conf_file}${lenny_chroot_suffix}"
  29.  
  30.     #Put entries in place
  31.     if [ -f $schroot_conf_file ];
  32.     then
  33.         #Old conf file exists, copy to archived
  34.     cp $schroot_conf_file $archived_schroot_conf_file
  35.         #Append additions
  36.     cat $archived_schroot_conf_file $new_schroot_conf_file > $schroot_conf_file
  37.     else
  38.         #No old file, copy over conf file
  39.     cp $new_schroot_conf_file $schroot_conf_file
  40.     fi    
  41.     rm -f $new_schroot_conf_file
  42.  
  43.     #Setup fstab
  44.     fstab_additions_file=/tmp/fstab_entries
  45.     cat <<FSTAB > $fstab_additions_file
  46.  
  47. # fstab: static file system information for chroots.
  48. #
  49. # <file system> <mount point>   <type>  <options>   <dump>  <pass>
  50. /proc       $chroot_location/proc       none    rw,bind        0       0
  51. /sys        $chroot_location/sys        none    rw,bind        0       0
  52. /tmp        $chroot_location/host/tmp   none    rw,bind        0       0
  53. /dev/pts    $chroot_location/dev/pts    none    rw,bind     0   0
  54. tmpfs       $chroot_location/dev/shm    tmpfs   defaults    0   0
  55. /usr/local/akamai       $chroot_location/usr/local/akamai   ext2    rw,bind     0   0
  56. /usr/local/akamai/logs      $chroot_location/usr/local/akamai/logs  ext2    rw,bind     0   0
  57. /usr/local/akamai/coredumps $chroot_location/usr/local/akamai/coredumps ext2    rw,bind     0   0
  58.  
  59. FSTAB
  60.     fstab_file=/etc/fstab
  61.     archived_fstab_file="/etc/fstab${lenny_chroot_suffix}"
  62.  
  63.     #Append to fstab
  64.     mv $fstab_file $archived_fstab_file
  65.     cat $archived_fstab_file $fstab_additions_file > $fstab_file
  66.     rm -f $fstab_additions_file
  67.    
  68.     #Assumes dpkg install as 'root'
  69.     mount -a #Complains about re-mount of /sys
  70.  
  71.     exit 0
  72. fi
Advertisement
Add Comment
Please, Sign In to add comment