samba share mount.

Here for general support for E series TVs, request and problem solve area.

leandrocaldas
Posts: 10
Joined: Fri Feb 03, 2017 6:32 pm

Re: samba share mount.

Post by leandrocaldas » Sat Feb 18, 2017 9:08 pm

juusso wrote:
Sat Feb 18, 2017 8:49 pm
And if you leave SHARES="movies" in init script? What do you get after reboot?
this is the point.. if I set SHARES="movies" not working(all folders are there), I checked the scrip and didn´t see $SHARES to get this information.

/bin/busybox mount -o "${M_OPTS}" -t cifs "//$1/$i" "$M_POINT"

should be

/bin/busybox mount -o "${M_OPTS}" -t cifs "//$1/$SHARES" "$M_POINT"

but this $i comes to:
this script is getting all shares files in my network and I just want one folder.

Code: Select all

get_shares()
{
	echo "Search Shares" 
	for i in $SERVERS ; do
	echo "on: $i" 
		S_MOUNTS=$(smbclient -s "$SYSROOT/etc/samba/smb.conf" -U ${USER}%${PASSWD} \
		-g -L $i | grep "Disk|" | grep -v "\\$" | grep -v " Service" | sed -r 's/.*\|(.*)\|.*/\1/' | sed -r 's/ /SGOspace/g')	
		# -g -L $i | grep "Disk|" | grep -v "\\$" | grep -v " Service" | cut -d "|" -f2)	
	[ -n "$S_MOUNTS" ] && do_mount $i
	done
my script

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: 04_04_samba.init 1069 2011-01-03 16:47:24Z arris69 $
#

. /dtv/SGO.env
# sleep 9
##### CHANGE MEEEEE !!!!! ######
USER="guest"
PASSWD="none"
PERM="rw" # can be ro or rw
##### CHANGE MEEEEE END ######

[ -e /mtd_rwarea/smb_userdata ] && source /mtd_rwarea/smb_userdata

[ -z $USER ] && exit 1
[ -z $PASSWD ] && exit 1

DEST_DIR=$MOUNT_PATH
SERVER="192.168.1.2"
# SERVER="10.0.0.1" # if you want a fixed server
SHARES="movies"
FR_NAME="midias"
# M_OPTS="rw,user=${USER},password=${PASSWD}"
M_OPTS="$PERM,user=${USER},password=${PASSWD},codepage=cp1250,iocharset=utf8"

SERVERS="Don't set me!!"


do_mount()
{
#		$(echo -e "[sdh]\nVendor : CifsMount\nProduct : $FR_NAME\n\
#Serial : Q80VQLFH\nDevpath : 8\nLun : 0\nMountDir : $DEST_DIR\nFileSystem : vfat\n" >> /dtv/usb/log)

	for i in $S_MOUNTS ; do
		i="$(echo -n $i | sed -e 's/SGOspace/ /g')"
		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}" -t cifs "//$1/$i" "$M_POINT"
		else
			echo "$M_POINT is mounted!"
		fi

	done
}

get_shares()
{
	echo "Search Shares" 
	for i in $SERVERS ; do
	echo "on: $i" 
		S_MOUNTS=$(smbclient -s "$SYSROOT/etc/samba/smb.conf" -U ${USER}%${PASSWD} \
		-g -L $i | grep "Disk|" | grep -v "\\$" | grep -v " Service" | sed -r 's/.*\|(.*)\|.*/\1/' | sed -r 's/ /SGOspace/g')	
		# -g -L $i | grep "Disk|" | grep -v "\\$" | grep -v " Service" | cut -d "|" -f2)	
	[ -n "$S_MOUNTS" ] && do_mount $i
	done
}

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)
	insmod $MOD_DIR/kernel/fs/cifs/cifs.ko
	mkdir -p "$DEST_DIR"
	get_servers
	get_shares
	;;
	stop)
	# may can fail if device access the mount from content library
	# for i in $(cat /proc/mounts | grep cifs | cut -d " " -f2) ; do
	for i in $(cat /proc/mounts | grep cifs | grep "$DEST_DIR" | sed 's/^\(.*\) \(.*\) cifs .*/\2/') ; do
		i="$(echo -n $i | sed -r 's/\\040/ /g')"
		/bin/busybox umount "$i"
	done
	;;
	status)
	/bin/mount | grep "$DEST_DIR"
	;;
	*)
	echo "Usage: $0 {start|stop}" 1>&2
	exit 0
	;;
esac


User avatar
juusso
SamyGO Moderator
Posts: 10125
Joined: Sun Mar 07, 2010 6:20 pm

Re: samba share mount.

Post by juusso » Sat Feb 18, 2017 9:55 pm

use this version of samba.init :)

Code: Select all

#!/bin/sh
#

. /dtv/SGO.env

case $1 in 
	start)
	insmod $MOD_DIR/kernel/fs/cifs/cifs.ko
	
	if [ ! -d /dtv/usb/sdj/movies ]; then
		mkdir -p /dtv/usb/sdj/movies
	fi

	if [ `mount | grep -c /dtv/usb/sdj/movies` == 0 ]; then
		/bin/busybox mount -o user=guest,password=none -t cifs //192.168.1.2/movies /dtv/usb/sdj/movies
	fi	
	;;
	stop)
	;;
	status)
	;;
	*)
	echo "Usage: $0 {start|stop}" 1>&2
	exit 0
	;;
esac

LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE

leandrocaldas
Posts: 10
Joined: Fri Feb 03, 2017 6:32 pm

Re: samba share mount.

Post by leandrocaldas » Sat Feb 18, 2017 10:09 pm

Thank you so much!!! worked fine!! I will make some modifications to attend if I need to change folders easy!!!

User avatar
juusso
SamyGO Moderator
Posts: 10125
Joined: Sun Mar 07, 2010 6:20 pm

Re: samba share mount.

Post by juusso » Sun Feb 19, 2017 7:23 am

Well, simple, but not universal. If you do not change your server IP/ sharenames often, then this will work. Also mounting of shares is being performed quicker.
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE

Post Reply

Return to “[E] Support”