Page 1 of 1

[D1600] Recording TV to NFS Share

Posted: Thu Jan 05, 2012 8:53 pm
by thetmyster
I am trying to record to NFS Share. I have got it to mount under Virt.Usb in folder :

Code: Select all

/nfs/server_ip/share
However I cant record to it.

It works with both the config files

Code: Select all

80_80_record_to_nwshare.init

Code: Select all

#!/bin/sh
#
# ? Copyleft 1996-2011, ZsoltTech.Com
#       by Ser Lev Arris <arris@ZsoltTech.Com>
#	based on research of:
#		andy_nl:	http://sourceforge.net/apps/phpbb/samygo/memberlist.php?mode=viewprofile&u=1728
#		gipas:		http://sourceforge.net/apps/phpbb/samygo/memberlist.php?mode=viewprofile&u=1751
#	http://sourceforge.net/apps/phpbb/samygo/viewtopic.php?f=12&t=1100&start=20#p10553
#
#       donated for the SamyGo Project
#       http://samygo.sourceforge.net/
#
# http://www.gnu.org/licenses/gpl-howto.html
#
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
# 
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script.  If not, see <http://www.gnu.org/licenses/>.
#

# 
# TODO: more sysv style, more error handling
#
# Modified by Remigio Conti 20110110
#

. /dtv/SGO.env

# Remote NFS fileserver for recording 
PVRSERVER='192.168.1.105'

# Remote NFS share for recording
PVRPATH='/Users/theobarber-bany/Movies/TV Cache'

# NFS mount options. If you experince problem like slow performance, try change this.
# M_OPTS="soft,udp,async,nolock,rsize=32768,wsize=8192"
# M_OPTS="rw,soft,udp,nolock,rsize=32768,wsize=32768"
# M_OPTS="soft,tcp,nolock,rsize=32768,wsize=32768"
# M_OPTS="soft,tcp,nolock,rsize=8192,wsize=8192"
M_OPTS="soft,tcp,nolock"

# Number of second to wait for pvrimage mount point to be ready. 
# If you experience problem like "No virtual device found ready for PVR or already mounted" message in samygo.log then try to increase this.
WAIT=25


WriteToLog ()
{
	case $2 in
		1)
		NOW=`date +%Y%m%d-%H%M%S`
		echo "$3" "$NOW $1" >>$LOGFILE
		;;
		2)
		echo "$3" "$1" >>$LOGFILE
		;;
	esac
}

CheckNFSServer ()
{
	WriteToLog "Check if server $1 is reachable and NFS service available..." 1 '-n'
	showmount --no-header -e $1 1>/dev/null 2>&1
	if [ $? = 0 ]; then		
		WriteToLog 'OK' 2
		return 0
	else
		echo "NFS server $1 not reachable or NFS service not available"
		WriteToLog 'not reachable or NFS service not available' 2
		return 1
	fi
}

SearchPVRImageMP ()
{
	FOUND=false
	WriteToLog 'Search for mount point of pvrimage...' 1
	sleep $WAIT
	for DEV in `echo $SAMYGODEVS`
	do
		MPOINT=`grep -e ^$DEV /proc/mounts | cut -d " " -f 2`
		if [ -e "$MPOINT/.PlaceHolderDO-NOT-REMOVE" ] && [ $FOUND = false ]; then
			PVRMPOINT=$MPOINT
			FOUND=true
			WriteToLog "pvrimage mount point is $PVRMPOINT" 1
		fi
	done

}

MountNFSShare ()
{
	WriteToLog "Mount of $2:$3 on $4... " 1 '-n'
	/bin/busybox mount -o "$1" "$2:$3" "$4" 2>>$LOGFILE

	if [ $? = 0 ]; then
		WriteToLog 'OK' 2
		CONTENTSDIR="$4/CONTENTS"
		if ! [ -d "$CONTENTSDIR" ]; then
			echo -n "Creating directory $CONTENTSDIR for the first time..."
			WriteToLog "Creating directory $CONTENTSDIR for the first time..." 1 '-n'
			mkdir "$CONTENTSDIR"
			echo "OK"
			WriteToLog 'OK' 2
			echo -n "Creating .PVRPfmChkLog file..."
			WriteToLog 'Creating .PVRPfmChkLog file...' 1 '-n'
			echo '1' > "$CONTENTSDIR/.PVRPfmChkLog"
			echo "OK"
			WriteToLog 'OK' 2
		fi
		echo "PVR on server $2 is now ready in localpath $4"
		WriteToLog "PVR on server $2 is now ready in localpath $4" 1
	else
		echo "Error during mount of $2:$3 on $4 see $LOGFILE for details"
	fi
}

case $1 in 
	start)
	echo >$LOGFILE
	WriteToLog 'Start Record to Network Share script (80_80_record_to_nwshare.init)' 1
	CheckNFSServer "$PVRSERVER"
	if [ $? = 0 ]; then
		SearchPVRImageMP

		if [ $FOUND = true ]; then
			MountNFSShare "$M_OPTS" "$PVRSERVER" "$PVRPATH" "$PVRMPOINT"	  
		else
			echo 'No virtual device found ready for PVR or already mounted'
			WriteToLog 'No virtual device found ready for PVR or already mounted' 1
		fi 
	fi
	WriteToLog 'End Record to Network Share script (80_80_record_to_nwshare.init)' 1	
	;;
	stop)
	echo "pls request it on forum"
	;;
	status)
	echo "pls request it on forum"
	;;
	*)
	echo "Usage: $0 {start|stop|status}" 1>&2
	exit 0
	;;
esac
and the script for the 03_03 (as well as remi17)

Code: Select all

03_03_nfsmount.init

Code: Select all

#!/bin/sh
#
# ? Copyright 1996-2010, ZsoltTech.Com
#       by Ser Lev Arris <arris@ZsoltTech.Com>
#
#       donated for the SamyGo Project
#       http://samygo.sourceforge.net/
#
#       Version: SamyGO svn $Id: 03_03_nfsmount.init 1069 2011-01-03 16:47:24Z arris69 $

. /dtv/SGO.env
# sleep 9
##### YOU CAN CHANGE ME HERE ######
SERVER="192.168.1.105"
# SERVER="10.0.0.1" # if you want a fixed server
SHARES="/Users/theobarber-bany/Movies/TV Cache"
# SHARES="Video Music Photo" # if you won't all your shares, but then set SERVER too!!
##### CHANGE ME END ######

FR_NAME="NFS Server"
# M_OPTS="soft,udp,async,nolock,rsize=32768,wsize=8192"
# M_OPTS="rw,soft,udp,nolock,rsize=32768,wsize=32768"
# M_OPTS="soft,tcp,nolock,rsize=32768,wsize=32768"
# M_OPTS="soft,tcp,nolock,rsize=8192,wsize=8192"
M_OPTS="soft,tcp,nolock"

SERVERS="Don't set me!!"

DEST_DIR=$MOUNT_PATH/nfs

do_mount()
{
#		$(echo -e "[sdg]\nVendor : NfsMount\nProduct : $FR_NAME\n\
#Serial : Q80VQLFG\nDevpath : 7\nLun : 0\nMountDir : $DEST_DIR\nFileSystem : vfat\n" >> /dtv/usb/log)
	
	for i in $S_MOUNTS ; do
		M_POINT="$DEST_DIR/$1/$(echo -n $i | sed -e "s/\//_/g")"
		mkdir -p "$M_POINT" 
		if [ `cat /proc/mounts | grep -c "$M_POINT"` -lt "1" ] ; then
			/bin/busybox mount -o "$M_OPTS" "$1:$i" "$M_POINT"
		else
			echo "$M_POINT is mounted!"
		fi
	done
}

get_shares()
{
	if [ -z "$SHARES" ] ; then
		echo -n "Search Shares on: "
		for i in $SERVERS ; do
			echo $i
			# S_MOUNTS=$(showmount --no-headers -e $i | cut -d " " -f1)	
			S_MOUNTS=$(showmount --no-headers -e $i | sed 's/^\(.*\) .*/\1/')	
			[ -n "$S_MOUNTS" ] && do_mount $i
		done
	else
		echo -n "Fixed Server: "
		for i in $SERVERS ; do
			echo $i
			S_MOUNTS=$SHARES
			[ -n "$S_MOUNTS" ] && do_mount $i
		done
	fi
}

get_servers()
{
	if [ -z "$SERVER" ] ; then
		# SERVERS=$(cat /proc/net/arp | grep -v "IP address" | cut -d " " -f1)
		SERVERS=$(cat /proc/net/arp | grep -v "IP address" | sed 's/^\(\w*.\w*.\w*.\w*\) *.*/\1/')
	else
		SERVERS=$SERVER
	fi
}

case $1 in 
	start)
	# for systems with modular nfs kernel support
	insmod $MOD_DIR/kernel/net/sunrpc/sunrpc.ko
	insmod $MOD_DIR/kernel/fs/lockd/lockd.ko
	insmod $MOD_DIR/kernel/fs/nfs_common/nfs_acl.ko
	insmod $MOD_DIR/kernel/fs/nfs/nfs.ko
	get_servers
	get_shares
	;;
	stop)
	# may can fail if device access the mount from content library
	# for i in $(cat /proc/mounts | grep nfs | cut -d " " -f2) ; do
	for i in $(cat /proc/mounts | grep "$DEST_DIR" | sed 's/^\(.*\) \(.*\) nfs .*/\2/') ; do
		/bin/busybox umount $i
	done
	;;
	status)
	/bin/mount | grep "$DEST_DIR"
	;;
	*)
	echo "Usage: $0 {start|stop|status}" 1>&2
	exit 0
	;;
esac

Thanks.
Theo.