Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/sbin/runscript
- # Copyright 1999-2009 Gentoo Foundation
- # Distributed under the terms of the GNU General Public License v2
- # $Header: $
- SQFS_DIRNAME=/var/img
- SQFS_CUR="$SQFS_DIRNAME/kernel.sqfs"
- SQFS_NEW="$SQFS_DIRNAME/kernel-current.sqfs"
- SQFS_OLD="$SQFS_DIRNAME/kernel-old.sqfs"
- [ ! $KERNDIR ] && KERNDIR="/depo/kernel"
- DEF_RW="/dev/shm/.kernel-rw"
- depend() {
- need localmount
- }
- start() {
- ebegin "Mounting read-only kernel squashfs image"
- [ -f $SQFS_CUR ] || {
- eend 1
- eerror "No squashfs image in $SQFS_CUR. Create image first!"
- einfo "You may use 'mksquashfs $KERNDIR $SQFS_CUR -no-duplicates' for it"
- return 1
- }
- mount -rt squashfs -o loop,nodev,noexec $SQFS_CUR $KERNDIR
- retval=$?
- eend $retval
- [ $retval -ne 0 ] && return $retval
- ebegin "Mounting read-write kernel image with unionfs (aufs2)"
- if [ ! $KERNEL_RW ]
- then
- einfo " mounted in tmpfs (actually RAM)"
- KERNEL_RW="${DEF_RW}"
- fi
- [ -d $KERNEL_RW ] || mkdir -p $KERNEL_RW
- chmod 777 $KERNEL_RW
- mount -t aufs -o nodev,noexec,dirs=$KERNEL_RW=rw:$KERNDIR=ro portAufs $KERNDIR
- eend $?
- }
- stop() {
- ebegin "Updating kernel image"
- [ ! $PORTAGE_RW ] && PORTAGE_RW="${DEF_RW}"
- if [ ! -z `ls -A $PORTAGE_RW | grep -v '.wh..wh.' | head -n1` ]
- then
- einfo " Syncing the image"
- mv -f $SQFS_NEW $SQFS_OLD
- mksquashfs $KERNDIR $SQFS_NEW -comp lzo -no-duplicates 2>/dev/null
- retval=$?
- ln -sf $SQFS_NEW $SQFS_CUR
- else
- einfo " Nothing to do"
- retval=0
- fi
- eend $retval
- ebegin "Unmounting kernel"
- umount -t aufs $KERNDIR
- umount -t squashfs $KERNDIR
- rm -rf $KERNEL_RW
- eend 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement