Advertisement
peetaur

ubuntu 14 preseed repack initrd

Jul 11th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. # Copies to the initrd, and also to the web dir but doesn't get used there.
  2. installfiles() {
  3.     seedfile="$1"
  4.     seedfilename=$(basename "$seedfile")
  5.    
  6.     basedir=/srv/tftp/netboot/ubuntu14.04/
  7.     webdir=/srv/www/netboot/ubuntu14.04
  8.    
  9.     if [ ! -e "$seedfile" ]; then
  10.         echo "ERROR: could not find seed file: $seedfile"
  11.         return 3
  12.     fi
  13.    
  14.     echo "Copying \"$seedfile\" to \"$webdir\""
  15.     cp "$seedfile" "$webdir"
  16.    
  17.     echo "Unpacking initrd.gz"
  18.     mkdir -p "$basedir"/tmp
  19.     rm -r "$basedir"/tmp/*
  20.     if [ ! -e "$basedir"/tmp/ ]; then
  21.         echo "ERROR: tmp dir could not be created"
  22.         return 1
  23.     fi
  24.     if [ ! -e "$basedir"/ubuntu-installer/amd64/initrd.gz ]; then
  25.         echo "ERROR: initrd.gz not found"
  26.         return 2
  27.     fi
  28.     cd "$basedir"/tmp/
  29.     gunzip -c "$basedir"/ubuntu-installer/amd64/initrd.gz | cpio -i
  30.    
  31.     echo "Packing \"$seedfilename\" into the initrd.gz (renamed to pressed.cfg)"
  32.     cp "$webdir"/"$seedfilename" preseed.cfg
  33.     find | cpio --create --format='newc' | gzip -c > "$basedir"/ubuntu-installer/amd64/initrd.gz
  34.    
  35.     echo "done"
  36. }
  37.  
  38. installfiles ~/ubuntu14.seed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement