description "unmounts normal MyDocs filesystem and replaces it with the SD card" # Runs afer rcS-late has mounted everything start on MOUNTS_OK console none script MYDOCS_DEVICE=/dev/mmcblk0p1 SD_DEVICE=/dev/mmcblk1p1 MYDOCS_MOUNTPOINT=/home/user/MyDocs MYDOCS_FILESYSTEM=vfat SD_MOUNTPOINT=/media/mmc1 SD_FILESYSTEM=ext3 # Check that MyDocs hasn't already been replaced if [ ! -z "`mount | grep $MYDOCS_MOUNTPOINT | grep $SD_DEVICE`" ] then # Already mounted. normal exit 0 fi # It can take a few seconds for MyDocs to actually mount after rsS-late # has finished, so we'll watch for it i=0 if [ $SD_FILESYSTEM == "vfat" ] then # The SD will auto-mount if if's vfat, but won't otherwise. So if it's vfat # we want to wait until it's been mounted so we don't interrupt while [ "`mount | grep $SD_MOUNTPOINT`" ] do i=$(($i+1)) if [ $i -eq 120 ] then # If it hasn't mounted within two minutes, something's gone # horribly wrong, so we may as well give up normal exit 0 fi sleep 1 done fi i=0 while [ -z "`mount | grep $MYDOCS_MOUNTPOINT`" ] do i=$(($i+1)) if [ $i -eq 120 ] then # If it hasn't mounted within two minutes, something's gone # horribly wrong, so we may as well give up normal exit 0 fi sleep 1 done if [ $SD_FILESYSTEM == "vfat" ] then # Get mount options from the fstab file OPTS=`grep $MYDOCS_MOUNTPOINT /etc/fstab | awk ' { print $4 } '` else # We don't want the mount options from fstab, as some are invalid for # other filesystems. OPTS="noauto,nodev,nosuid,noatime,nodiratime" fi if [ $SD_FILESYSTEM == "vfat" ] then # Unmount the SD card umount $SD_MOUNTPOINT # Check it unmouted OK if [ $? -ne 0 ] then exit fi fi # Unmount the MyDocs filesystem umount $MYDOCS_MOUNTPOINT # Check it unmounted OK if [ $? -eq 0 ] then # Mount the SD on MyDocs mount $SD_DEVICE -t $SD_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT if [ $? -ne 0 ] then # Failed to mount the SD so fall back to original mount $MYDOCS_DEVICE -t $MYDOCS_FILESYSTEM -o "$OPTS" $MYDOCS_MOUNTPOINT else initctl emit MYDOCS_REPLACED fi fi end script normal exit 0