#!/bin/sh
MERAKI_BOARD=`cat /MERAKI_BOARD`

if [ -e /dev/sda -a "$MERAKI_BOARD" == "apvirtual" ]; then
    STORAGE_DEV=`findfs LABEL=virt_storage || echo /dev/sda`
    echo Found storage device for Virtual AP: $STORAGE_DEV

    e2fsck -p -f $STORAGE_DEV
    if [ $? -le 1 ]; then
        mount -t ext3 $STORAGE_DEV /storage
    else
        echo "e2fsck failed for /storage; reformatting: $e_rc"
        sync
        umount /storage
        mkfs.ext3 -F -L virt_storage -c $STORAGE_DEV
        mount -t ext3 $STORAGE_DEV /storage
        #touch /storage/reformatted_partition
    fi
fi
