rendered paste bodymmc_mount_root=$(nvram get mmc_mount_root)
mmc_mount_root=${mmc_mount_root:-/tmp/.mmc}
mmc_mount_point=$(nvram get mmc_mount_point)
mmc_mount_point=${mmc_mount_point:-/mmc}
[ -f /tmp/.mmc-status ] || {
echo 0 > /tmp/.mmc-status
}
[ -d "$mmc_mount_root" ] || {
mkdir "$mmc_mount_root"
}
[ -e "$mmc_mount_point" ] || {
ln -s $mmc_mount_root $mmc_mount_point
}
mmc_status=`cat /tmp/.mmc-status`
nvram set mmc_mount_root="$mmc_mount_root"
nvram set mmc_mount_point="$mmc_mount_point"
case $1 in
insert)
[ "$mmc_status" = "1" ] && {
echo "MMC Card already present!"
} || {
insmod -q fat
insmod -q vfat
insmod -q mmc
sleep 1
mkdir -p $mmc_mount_root
mount /dev/mmc/disc0/part1 $mmc_mount_root
echo 1 > /tmp/.mmc-status
echo "MMC Card mounted at $mmc_mount_point"
}
;;
eject)
[ "$mmc_status" = "0" ] && {
echo "MMC Card not present!"
} || {
umount $mmc_mount_root || exit 1
sleep 1
rmmod mmc
rmmod vfat
rmmod fat
echo 0 > /tmp/.mmc-status
rmdir $mmc_mount_root
echo "MMC Card unmounted from $mmc_mount_point"
}
;;
*)
echo "Usage: mmc <insert|eject>"
;;
esac