#!/sbin/runscript # script that will mount image with modules # read kernel options for i in `cat /proc/cmdline` ; do case $i in *=*) eval KOPT_$i ;; *) eval KOPT_$i=yes ;; esac done find_media() { ALPINE_DEV=${KOPT_alpine_dev%%:*} ALPINE_MNT=`awk '/^\/dev\/'$ALPINE_DEV'/ { print $2 }' /etc/fstab` } start() { local rc= local imgdir=$(dirname ${KOPT_BOOT_IMAGE:-""}) find_media if [ -z "$ALPINE_DEV" ] ; then ebegin "Skipping mount media with modules (specify with alpine_dev)" eend 0 return 0 fi if [ -n "$KOPT_modloop" ]; then CMG="$ALPINE_MNT/$KOPT_modloop" else CMG=$ALPINE_MNT/$imgdir/modloop.cmg fi ebegin "Mounting loopback device for kernel modules" modprobe loop >/dev/null 2>&1 &&\ mount $ALPINE_MNT >/dev/null 2>&1 &&\ mkdir -p /.modloop &&\ if [ ! -f "$CMG" ] ; then CMG=$ALPINE_MNT/$imgdir/modules.cmg fi &&\ mount -o loop,ro -t cramfs $CMG /.modloop rc=$? if [ "$rc" = 0 ]; then rm -rf /lib/modules ln -sf /.modloop/modules /lib fi # copy firmware if there are any if [ -d $ALPINE_MNT/firmware ]; then mkdir -p /lib/firmware cp $ALPINE_MNT/firmware/* /lib/firmware/ fi eend $rc } stop() { find_media if [ "$ALPINE_DEV" ] ; then ebegin "Unmounting loopback device for kernel modules" umount -d /.modloop &&\ umount $ALPINE_MNT 2>/dev/null eend $? fi }