#!/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/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
    if [ $i -eq 1 ]
    then
        mydir="/dev/dvb/adapter_${my_base}"
    else
        mydir="/dev/dvb/adapter_${my_base}-$i"
    fi
    if [ ! -e $mydir ]
    then
        ln -s $lndir  $mydir
        exit 0
    else
        echo "dvb $mydir already exists"
    fi
done
exit 0
