Name instead of IP for SAMBA shares

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

User avatar
brunogts77
Posts: 772
Joined: Sat Feb 18, 2012 8:34 pm

Name instead of IP for SAMBA shares

Post by brunogts77 »

Hi, it?s possible to configure samba in order to see the all shared devices on the network by name and not by your ip?
UE40JU6000 T-MST12DEUC_1119]
UE55JU6870 T-HKMDEUC-1480 [OSCAM=ON]
DEUS
Official SamyGO Developer
Posts: 316
Joined: Mon Feb 06, 2012 12:05 pm
Location: Germany

AW: Samba on D5700

Post by DEUS »

Ok found it by myself, this might be possible by get hostname via arp or lookup and then use it instead of IP. But you need to modify initi script. Normally nmbd is used to get hostname front wins
User avatar
brunogts77
Posts: 772
Joined: Sat Feb 18, 2012 8:34 pm

Re: Samba on D5700

Post by brunogts77 »

Can you help me to modify the init script?
UE40JU6000 T-MST12DEUC_1119]
UE55JU6870 T-HKMDEUC-1480 [OSCAM=ON]
DEUS
Official SamyGO Developer
Posts: 316
Joined: Mon Feb 06, 2012 12:05 pm
Location: Germany

Re: Samba on D5700

Post by DEUS »

to get the right hostname if nmblookup is there modification should be easy

Code: Select all

$DISTROOT/usr/bin/nmblookup -A "IP" | /bin/busybox awk 'NR==2 { print $1}'
User avatar
brunogts77
Posts: 772
Joined: Sat Feb 18, 2012 8:34 pm

Re: Samba on D5700

Post by brunogts77 »

DEUS wrote:to get the right hostname if nmblookup is there modification should be easy

Code: Select all

$DISTROOT/usr/bin/nmblookup -A "IP" | /bin/busybox awk 'NR==2 { print $1}'
Thanks Deus. But, where do I put this "$DISTROOT/usr/bin/nmblookup -A "IP" | /bin/busybox awk 'NR==2 { print $1}" Code?

This is my smb fille:
    . /dtv/SGO.env
    # sleep 9
    ##### CHANGE MEEEEE !!!!! ######
    USER="sysadmin"
    PASSWD="123456789"
    PERM="rw" # can be ro or rw
    ##### CHANGE MEEEEE END ######

    rm -fr /mtd_contents/database/

    [ -e /mtd_rwarea/smb_userdata ] && source /mtd_rwarea/smb_userdata
    [ -z $USER ] && exit 1
    [ -z $PASSWD ] && exit 1

    DEST_DIR=$MOUNT_PATH/smb
    SERVER=""
    # SERVER="10.0.0.1" # if you want a fixed server
    SHARES=""
    FR_NAME="Samba Server"
    # 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
    UE40JU6000 T-MST12DEUC_1119]
    UE55JU6870 T-HKMDEUC-1480 [OSCAM=ON]
    User avatar
    juusso
    SamyGO Moderator
    Posts: 10128
    Joined: Sun Mar 07, 2010 6:20 pm

    Re: Samba on D5700

    Post by juusso »

    brunogts77 wrote:...
    Some general forum rules:
    Please use tags for your code (debug output, scripts, bash commands and so on.)
    Quote just only important, but not whole posts.
    tag_code.PNG
    This helps to understand you better. Thanks for understanding. :!:
    You do not have the required permissions to view the files attached to this post.
    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
    User avatar
    brunogts77
    Posts: 772
    Joined: Sat Feb 18, 2012 8:34 pm

    Re: Samba on D5700

    Post by brunogts77 »

    Anny help?? Where do I put this "$DISTROOT/usr/bin/nmblookup -A "IP" | /bin/busybox awk 'NR==2 { print $1}" Code?
    UE40JU6000 T-MST12DEUC_1119]
    UE55JU6870 T-HKMDEUC-1480 [OSCAM=ON]
    DEUS
    Official SamyGO Developer
    Posts: 316
    Joined: Mon Feb 06, 2012 12:05 pm
    Location: Germany

    Re: Samba on D5700

    Post by DEUS »

    first you are just requesting help so be patient, did you tried it by yourself? no success?
    original line

    Code: Select all

    M_POINT="$DEST_DIR/$1/$(echo -n $i | sed -e "s/\\\$/_/g")"
    for name resolution via wins

    Code: Select all

    M_POINT="$DEST_DIR/$($DISTROOT/usr/bin/nmblookup -A "$1" | /bin/busybox awk 'NR==2 { print $1}')/$(echo -n $i | sed -e "s/\\\$/_/g")"
    for name resolution via dns

    Code: Select all

    M_POINT="$DEST_DIR/$($SYSROOT/bin/busybox nslookup "$1" | /bin/busybox awk 'NR==5 { print $4}' | /bin/busybox awk -F '.' '{ print $1}')/$(echo -n $i | sed -e "s/\\\$/_/g")"
    
    maybe you see how easy this could be just did a quick test and works in my enviorment
    User avatar
    brunogts77
    Posts: 772
    Joined: Sat Feb 18, 2012 8:34 pm

    Re: Samba on D5700

    Post by brunogts77 »

    Thanks Deus. It works fine! Very, very, very thanks.
    UE40JU6000 T-MST12DEUC_1119]
    UE55JU6870 T-HKMDEUC-1480 [OSCAM=ON]
    Spoza
    Posts: 252
    Joined: Wed Jan 18, 2012 10:41 pm

    Re: Samba on D5700

    Post by Spoza »

    Can this be included in the extensions pack? It seems to be VERY useful step towards average users.
    PS59D6900 T-MST5DEUC-1023.0

    Post Reply

    Return to “[D] Support”