#!/bin/bash
#
# Created Iscan_Adm for sharing panel
#
# /tmp/cccam_available_shares.info
# /tmp/cccam_hop1.info  CW0 -info
# /tmp/cccam_hop2.info  CW1 -info
# /tmp/cccam_onlineservers.info - info ip or name server
#

############ CAMD3 ###############

cd /tmp

FILENAME=/tmp/ecm.info
. /var/config/emu.conf

if [ $emu=camd3 ]
then
rm -f /tmp/cccam_clients
echo "EMU:$emu" > /tmp/cccam_clients.info

echo > /tmp/all.info

n=1
for user in $(grep CW $FILENAME)
do
 b=`expr substr $user 1 16`
echo Line[$n]=$b >> /tmp/all.info
let "n += 1"
done

m=50
for user in $(grep CAID $FILENAME)
do
 c=`expr substr $user 1 16`
echo Line[$m]=$c >> /tmp/all.info
let "m += 1"
done

k=100
for user in $(grep FROM $FILENAME)
do
 d=`expr substr $user 1 16`
echo Line[$k]=$d >> /tmp/all.info
let "k += 1"
done

. /tmp/all.info

rm -f cccam_hop1.info
for index1 in 1 2 3 4 5 6 7 8 9
do
printf "${Line[index1]}" >> /tmp/cccam_hop1.info
done

rm -f cccam_hop2.info
for index2 in 10 11 12 13 14 15 16 17 18
do
printf "${Line[index2]}" >> /tmp/cccam_hop2.info
done

rm -f /tmp/cccam_available_shares.info
for index3 in 50 51 52 53 54 55 56 57 58
do
printf "${Line[index3]}" >> /tmp/cccam_available_shares.info
done

rm -f /tmp/cccam_onlineservers.info
for index4 in 101 102 103 104 105 106 107 108
do
printf "${Line[index4]}" >> /tmp/cccam_onlineservers.info
done

else
 echo "1"
fi 

exit 0
