#!/bin/sh first() { echo "$1" } mountpoint_device() { grep "$1" /etc/fstab | awk '{print $1}' } check_repair_fs() { DEVICE="$1" MOUNTPOINT="$2" NAME="$3" if ! [ -e "$DEVICE" ]; then return 0 fi mount -o remount,ro "$DEVICE" fsck.vfat -y "$DEVICE" if [ $? -le 3 ]; then mount -o remount,rw "$DEVICE" else return $? fi } # FIXME: a bit more flexible if ! check_repair_fs $(first /dev/mmcblk*) /media/sd "SD card"; then emessage "Filesystem on SD card is damaged. Please reformat or repair it." fi if ! check_repair_fs $(mountpoint_device /mnt/storage) /mnt/storage "Internal storage"; then emessage "Internal storage filesystem is damaged. Please attach device to computer and reformat or repair it."& usbwatcher& while true; do sleep 10000; done fi