#! /bin/bash

mount_point=/data0

sda=$(ls /dev/sda | wc -l)
if [ $sda != 1 ];then
    echo 硬盘不存在
    exit 1
fi
echo 硬盘存在
if [ -d "${mount_point}" ];then
    echo 缓存目录存在
else
    echo 创建目录
    mkdir "${mount_point}"
fi

while true
do
    is_mounted=$(mount | grep /dev/sda | grep ${mount_point} | wc -l)
    if [ "${is_mounted}" -eq 0 ]; then
        echo "未挂载，尝试挂载"
        echo "mount -o rw,noatime,nodiratime /dev/sda ${mount_point}"
        mount -o rw,noatime,nodiratime /dev/sda "${mount_point}"
    else
        sleep 10
    fi
done
