Advertisement
linuxophilicsb

update_initrd.sh

Jun 25th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.36 KB | None | 0 0
  1. #!/bin/sh
  2. #Update Zeroshell initrd.gz
  3. #30th May 2012
  4. #This code was written using :
  5. #http://edwidianto.wordpress.com/2010/06/04/instalasi-dan-update-zeroshell-1-0-beta12-retro/#
  6. #
  7.  
  8. show_error() {
  9.         echo"$1"
  10.         exit
  11. }
  12.  
  13. INITRD_TARGET_DIR=/mnt/initrd
  14.  
  15. LOOP_MOD='loop.ko'
  16.  
  17. LOOP_TARGET_DIR=/lib
  18.  
  19.  
  20. SATA_CHIP_MOD='sata_inic162x.ko sata_mv.ko sata_nv.ko sata_promise.ko sata_qstor.ko sata_sil24.ko sata_sil.ko sata_sis.ko sata_svw.ko sata_sx4.ko sata_uli.ko sata_via.ko sata_vsc.ko'
  21.  
  22. SATA_CHIP_TARGET_DIR=/lib/sata/chipsets
  23.  
  24. SATA_DEPS_MOD='libata.ko pata_sis.ko'
  25.  
  26. SATA_DEPS_TARGET_DIR=/lib/sata/deps
  27.  
  28.  
  29. USB_HOST_MOD='ehci-hcd.ko isp116x-hcd.ko ohci-hcd.ko r8a66597-hcd.ko sl811-hcd.ko u132-hcd.ko uhci-hcd.ko'
  30.  
  31. USB_HOST_TARGET_DIR=lib/usb/host
  32.  
  33. USB_STORAGE_MOD='sr_mod.ko usb-storage.ko'
  34.  
  35. USB_STORAGE_TARGET_DIR=/lib/usb/storage
  36.  
  37. USB_DEPS_MOD='ftdi-elan.ko ssb.ko'
  38.  
  39. USB_DEPS_TARGET_DIR=/lib/usb/deps
  40.  
  41. echo "various module names and their target directories stored ..for future copy to target dirs in the initrd image..";#sleep 10
  42. #Mount initrd.gz
  43.  
  44.  
  45. cp ./initrd.gz /tmp/
  46.  
  47. gzip -d /tmp/initrd.gz
  48.  
  49. #Check if already mounted
  50.  
  51. mount | grep -qe "$INITRD_TARGET_DIR" && umount $INITRD_TARGET_DIR
  52.  
  53. mount /tmp/initrd -o loop $INITRD_TARGET_DIR
  54. #Copy to target
  55.  
  56.  
  57.  
  58. copy_target() {
  59.    
  60.     for file in $1; do
  61.        
  62.         SRC_MOD="`find /lib/modules/2.6.39.4/ -type f -iname $file`"
  63.          
  64.         if [ "$SRC_MOD" == "" ];then
  65.    
  66.             echo "Warning: $file doesn't exist."
  67.  
  68.             continue # just give a warning
  69.  
  70.         else
  71.             echo "$SRC_MOD FOUND";
  72.             cp -af $SRC_MOD $INITRD_TARGET_DIR/$2
  73.         fi
  74.  
  75.     done
  76.     }
  77.  
  78. echo "Copying loop modules..." ;#sleep 10
  79.  
  80. copy_target $LOOP_MOD $LOOP_TARGET_DIR
  81.  
  82. echo
  83.  
  84.  
  85. echo "Copying sata_chip modules..."
  86.  
  87. copy_target "$SATA_CHIP_MOD" $SATA_CHIP_TARGET_DIR
  88.  
  89. "Copying sata_deps modules..."
  90.  
  91. copy_target "$SATA_DEPS_MOD" $SATA_DEPS_TARGET_DIR
  92.  
  93. echo
  94.  
  95.  
  96. echo "Copying usb_host modules..."
  97.  
  98. copy_target "$USB_HOST_MOD" $USB_HOST_TARGET_DIR
  99.  
  100.  
  101. echo "Copying usb_storage modules..."
  102.  
  103. copy_target "$USB_STORAGE_MOD" $USB_STORAGE_TARGET_DIR
  104.  
  105.  
  106. echo "Copying usb_deps modules..."
  107.  
  108. copy_target "$USB_DEPS_MOD" $USB_DEPS_TARGET_DIR
  109.  
  110.  
  111. #Umount initrd & create initrd.gz
  112.  
  113. mount | grep -qe "$INITRD_TARGET_DIR" && umount $INITRD_TARGET_DIR
  114. echo "unmounted $INITRD_TARGET_DIR" ;
  115. gzip /tmp/initrd #compress it
  116.  
  117. cp -f /tmp/initrd.gz ./
  118.  
  119.  
  120. echo "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement