Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2013
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/sbin/runscript
  2. # Copyright 1999-2009 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: $
  5.  
  6. SQFS_DIRNAME=/var/img
  7. SQFS_CUR="$SQFS_DIRNAME/kernel.sqfs"
  8. SQFS_NEW="$SQFS_DIRNAME/kernel-current.sqfs"
  9. SQFS_OLD="$SQFS_DIRNAME/kernel-old.sqfs"
  10. [ ! $KERNDIR ] && KERNDIR="/depo/kernel"
  11. DEF_RW="/dev/shm/.kernel-rw"
  12.  
  13. depend() {
  14. need localmount
  15. }
  16.  
  17. start() {
  18. ebegin "Mounting read-only kernel squashfs image"
  19. [ -f $SQFS_CUR ] || {
  20. eend 1
  21. eerror "No squashfs image in $SQFS_CUR. Create image first!"
  22. einfo "You may use 'mksquashfs $KERNDIR $SQFS_CUR -no-duplicates' for it"
  23. return 1
  24. }
  25. mount -rt squashfs -o loop,nodev,noexec $SQFS_CUR $KERNDIR
  26. retval=$?
  27. eend $retval
  28. [ $retval -ne 0 ] && return $retval
  29.  
  30. ebegin "Mounting read-write kernel image with unionfs (aufs2)"
  31. if [ ! $KERNEL_RW ]
  32. then
  33. einfo " mounted in tmpfs (actually RAM)"
  34. KERNEL_RW="${DEF_RW}"
  35. fi
  36. [ -d $KERNEL_RW ] || mkdir -p $KERNEL_RW
  37. chmod 777 $KERNEL_RW
  38. mount -t aufs -o nodev,noexec,dirs=$KERNEL_RW=rw:$KERNDIR=ro portAufs $KERNDIR
  39. eend $?
  40. }
  41.  
  42. stop() {
  43. ebegin "Updating kernel image"
  44. [ ! $PORTAGE_RW ] && PORTAGE_RW="${DEF_RW}"
  45. if [ ! -z `ls -A $PORTAGE_RW | grep -v '.wh..wh.' | head -n1` ]
  46. then
  47. einfo " Syncing the image"
  48. mv -f $SQFS_NEW $SQFS_OLD
  49. mksquashfs $KERNDIR $SQFS_NEW -comp lzo -no-duplicates 2>/dev/null
  50. retval=$?
  51. ln -sf $SQFS_NEW $SQFS_CUR
  52. else
  53. einfo " Nothing to do"
  54. retval=0
  55. fi
  56. eend $retval
  57.  
  58. ebegin "Unmounting kernel"
  59. umount -t aufs $KERNDIR
  60. umount -t squashfs $KERNDIR
  61. rm -rf $KERNEL_RW
  62. eend 0
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement