#!/bin/bash
my_base=$1
dev_name=$2
#DEVNAME=/dev/dvb/adapter2/frontend0
#DVB_ADAPTER_NUM=2

lndir=`dirname $dev_name`
#for clink in `ls -d /dev/vstatic/dvb*`
for clink in `ls -d /dev/dvb/adapter_*`
do
   if [ `readlink $clink` == $lndir ]
   then
       echo "link is already present $clink"
       exit 0
   fi

done
mkdir -p /dev/vstatic
for i in 1 2 3 4
do

    #mydir="/dev/vstatic/${my_base}_$i"
    mydir="/dev/dvb/adapter_static_${my_base}_$i"
    if [ ! -e $mydir ]
    then
        ln -s $lndir  $mydir
        exit 0
    else
        echo "dvb dir already exists "
    fi
done
exit 0

