start on MYDOCS_REPLACED
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 # Alter the next six lines if necessary for your system MYDOCS_DEVICE=/dev/mmcblk0p1 SD_DEVICE=/dev/mmcblk1p1 MYDOCS_MOUNTPOINT=/home/user/MyDocs MYDOCS_FILESYSTEM=vfat SD_MOUNTPOINT=/media/mmc1 SD_FILESYSTEM=vfat # 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 while [ -z "`mount | grep $MYDOCS_MOUNTPOINT`" -o -z "`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 # Get mount options from the fstab file OPTS=`grep $MYDOCS_MOUNTPOINT /etc/fstab | awk ' { print $4 } '` # Unmount the SD card umount $SD_MOUNTPOINT # Check it unmouted OK if [ $? -eq 0 ] then # 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 fi end script normal exit 0