daily pastebin goal
36%
SHARE
TWEET

update-initrd-pvscsi.sh

a guest Apr 20th, 2012 216 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # Newest initrd file is the one we want to update.
  4. filename=`ls -1ct /boot/initrd-*.img | head -n 1`
  5. echo "Newest initrd image found: ${filename}"
  6.  
  7. # Crop info from the initrd to get the kernel version.
  8. version=`basename ${filename} .img | cut -c 8-`
  9. echo "Version cropped from initrd filename: ${version}"
  10.  
  11. # Get the kernel suffix to see if it's PAE or normal.
  12. suffix=${version:(-3)}
  13. echo "Last three characters of the version: ${suffix}"
  14.  
  15. # If the string isn't null, proceed processing.
  16. if [ -n ${version} ]; then
  17.   # Remove the initrd generated by yum update.
  18.   echo -n "Removing initrd file ${filename} ... "
  19.   /bin/rm -f ${filename}
  20.   echo "Done!"
  21.  
  22.   # Make the module directory and copy all appropriate modules.
  23.   if [ ! -d "/lib/modules/${version}/misc" ]; then
  24.     echo -n "No existing /lib/modules/${version}/misc directory. Creating ... "
  25.     /bin/mkdir -p /lib/modules/${version}/misc
  26.     echo "Done!"
  27.  
  28.     if [ "$suffix" = "PAE" ]; then
  29.       echo -n "PAE kernel detected. Copying modules from /usr/lib/vmware-tools/modules/u3/PAE ... "
  30.       /bin/cp /usr/lib/vmware-tools/modules/u3/PAE/*.ko /lib/modules/${version}/misc
  31.       echo "Done!"
  32.     else
  33.       echo -n "Regular kernel detected. Copying modules from /usr/lib/vmware-tools/modules/u3/smp ... "
  34.       /bin/cp /usr/lib/vmware-tools/modules/u3/smp/*.ko /lib/modules/${version}/misc
  35.       echo "Done!"
  36.     fi
  37.   fi
  38.  
  39.   # Rebuild the module cache.
  40.   echo -n "Rebuilding the module cache ... "
  41.   /sbin/depmod -a ${version}
  42.   echo "Done!"
  43.  
  44.   # Make the new initrd file.
  45.   echo -n "Making new initrd file ${filename} ... "
  46.   /sbin/mkinitrd --with=pvscsi ${filename} ${version}
  47.   echo "Done!"
  48. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top