#!/bin/sh
PORT=6544
OFFSET=10
#録画・視聴中に動作しない場合
if [ `wget http://localhost:$PORT/ -O - -o /dev/null | \
 grep /dev/dvb/adapter | grep -c "recording"` -eq 0 ]
#視聴中は構わず再マウントする場合
#if [ `wget http://localhost:$PORT/ -O - -o /dev/null | \
# grep /dev/dvb/adapter | grep -c " is recording."` -eq 0 ]
then
	for ADAPTER in 0 1 2 3
	do
		NEW_ADAPTER=`expr $ADAPTER + $OFFSET`
		umount /dev/dvb/adapter$NEW_ADAPTER
		if [ $? -eq 0 ]
		then
			sleep 1
			nice --4 /usr/local/bin/fuse_b25 --target /dev/dvb/adapter$ADAPTER /dev/dvb/adapter$NEW_ADAPTER -o allow_other
		fi
done
fi
