#!/bin/bash

# NAS挂载脚本
NAS_URL="//cfdaily:Ccf7561523@192.168.2.154/stock"
MOUNT_POINT="/Users/chufeng/nas/stock"

# 创建挂载点（如果不存在）
mkdir -p "$MOUNT_POINT"

# 检查是否已经挂载
if mount | grep -q "$MOUNT_POINT"; then
    echo "NAS已经挂载在 $MOUNT_POINT"
    exit 0
fi

# 等待网络就绪（最多等待30秒）
for i in {1..30}; do
    if ping -c 1 192.168.2.154 &> /dev/null; then
        break
    fi
    sleep 1
done

# 尝试挂载
echo "正在挂载NAS..."
if /sbin/mount_smbfs "$NAS_URL" "$MOUNT_POINT"; then
    echo "NAS挂载成功：$MOUNT_POINT"
else
    echo "NAS挂载失败"
    exit 1
fi
