I have two Humax (HDs not HDRs) boxes and have for a while been mounting Samba shares so I can access or copy files between the two. I have found though that if box A is switched off then it causes a problem on box B when trying to open the Media menu (I mount my shares as another drive called "other" i.e. mounted to /media/other), the Media screen hangs as it is trying to to read volume information from a now disconnected source. My solution to this is the following script which loads on boot from /mod/etc/init.d, I thought I'd post it incase anyone else could use (or probably improve) it. Might also be useful for connecting to a PC which may or may not be turned on:
Code:
#!/bin/sh
#pings other box every 5 minutes, if responds mounts share (retries every 5 mins if fails)
#once connected tests other box is still on by pinging every 5 minutes, if no ping unmounts
#and returns to pinging to reconnect
exec >/tmp/connectShare.log 2>&1 #output errors to this file
mountpoint='/media/other'
#share='//192.168.1.xx/Media' #Box A
share='//192.168.1.xx/Media' #Box B
options='user=guest,password=guest'
ip=${share:2:12} #extract IP only from share address - or replace with actual IP/hostname
case "$1" in
start)
sleep 2 #allow time for network to initialise
while [ 1 ]; do #infinite loop
count="0"
while [ "$count" == "0" ]; do #keep looping until other box pings
temp=$(ping -c 2 $ip | grep 'received') #ping other box, keep only results line of output
count=${temp:23:1} #extract value of received packets (will be 0, 1 or 2)
if [ $count == "0" ]
then
echo "no response from " $ip "
sleep 300
fi
done
mkdir -p $mountpoint
result="1"
while [ $result != "0" ]; do
mount -t cifs $share $mountpoint -o $options
result=$?
echo "mount result:" $result
sleep 180
done
count='1'
while [ "$count" != "0" ]; do #keep looping while other box pings
sleep 300
temp=$(ping -c 2 $ip | grep 'received') #ping other box, keep only results line of output
count=${temp:23:1} #extract value of received packets (will be 0, 1 or 2)
if [ $count == "0" ]
then
echo $ip " stopped responding"
fi
done
result="1"
while [ $result != "0" ]; do #unmount, if fails wait 60 sec and retry
umount "$mountpoint"
result=$?
echo "umount result:" $result
sleep 60
done
rmdir "$mountpoint"
done
;;
stop)
umount "$mountpoint"
rmdir "$mountpoint"
;;
*)
exit 1
;;
esac