Denna funkar om man behöver både hängslen och livrem.
# Mount remote NAS directory for video recording
# DM800/8000 specific!
#!/bin/sh
HOST="192.168.1.102"
NETDIR="/mnt/HD/HD_b2"
TARGETDIR="/media/net"
MNTOPT="-o rw,nolock,soft,bg"
LOGFILE="/media/hdd/netmon.log"
D=$(date +'%Y/%m/%d %H:%M:%S')
# First, See if we can contact host
ping -c 1 $HOST > /dev/null
if [ $? -gt 0 ]; then
echo -e $D" Host is down!" >>$LOGFILE; exit;
fi
echo -e "Host is up, checking mount..."
# Check remote directory...
if [ -e $TARGETDIR"/movie" ]; then echo -e "Mount ok..."; exit;
else echo -e $D" Network path down, attempting re-mount..." >>$LOGFILE;
fi
/bin/mount $MNTOPT $HOST":"$NETDIR $TARGETDIR > /dev/null
if [ $? -eq 0 ]; then
echo -e $D" Remote Mount Ok" >>$LOGFILE;
else
echo -e $D" Mount error = "$?", retrying..." >>$LOGFILE
# Try one more time...
/bin/umount $TARGETDIR
sleep 1
/bin/mount $MNTOPT $HOST":"$NETDIR $TARGETDIR > /dev/null
if [ $? -eq 0 ]; then
echo -e $D" Remote Mount Ok" >>$LOGFILE;
else
echo -e $D" Mount error = "$? >>$LOGFILE;
fi
fi
exit