• Olá Visitante, se gosta do forum e pretende contribuir com um donativo para auxiliar nos encargos financeiros inerentes ao alojamento desta plataforma, pode encontrar mais informações sobre os várias formas disponíveis para o fazer no seguinte tópico: leia mais... O seu contributo é importante! Obrigado.

Script para correr 2 Cccam em simultaneo

obelix699

GF Prata
Membro Inactivo
Entrou
Mai 1, 2007
Mensagens
391
Gostos Recebidos
0
Eu ja tinha postado este script noutro topico mas aqui fica arrumadinho :)


More then 1 CCcam on same PC with differend nodeid

'' Its about more then one CCcam on 1 PC and i have to say i tested i just on a pc and not on a dreambox,
with in my case Ubuntu installed on it, but it works on more linux distro's , centos , debian and so on..
I did read a lot of requests on differend forums about more then 1 CCcam's on the same PC,
and because of everyone who was trying, had the same problem and that are that the CCcams running
on the same PC had the same NodeID.
When you do this you have to set differend ports for every CCcam!!
And i had some sparetime for my hobby anyway, so i took a shot at it and solved the problem.
First we have to name all the CCcam's like this CCcam_1.x86 and the config like CCcam_1.cfg and so on.
the .x86 is important or sometimes the cam's won't start. So don't change that if you want to use it.
the CCcam's starting is done like this. /usr/local/bin/CCcam_1.x86 -C /var/etc/CCcam_1.cfg
So now the trick, when i was testing i saw the same nodeid no big suprice because everyone did know that.
What happens is that when you start CCcam it writtes down the nodeid in /tmp/ like /tmp/.CCcam.nodeid
But when you start the second CCcam it takes over the Nodeid from CCcam that started befor.
so i thought what will happen when i delete the nodeid from the CCcam when it is running,
so i did and there was nothing changed CCcam was still running perfect without any problems so i started the second CCcam
and it had a new and differend nodeid so problem solved ! easy ??? yes !!
But when you have to start al the cam's al the time manualy then you have a big job, so i made some nice small
scripts to run it all easely to start, stop, check the cam's running and config updates.
Bud you have to make some new directory's
/var/cccamlog for the logfiles /var/scripts for the scripts and /var/config and /var/backup for the config files
the script makes a backup from the config befor the last changes.
in some scripts you have to fill in your username from the distro that you use. on the plases with ?????????
and what to do to remove the nodeid is the command :

chown yourusername /tmp/.CCcam.nodeid ----> to get the rights to remove the file.

Then the remove and start command:

rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_2.x86 -C /var/etc/CCcam_2.cfg

and this you need to do for all the next to start CCcam's. i have tested it till 10 CCcam's just for fun.
the script are made easy to add extra lines colored in yellow for each extra CCcam you add.
all the Cam's and configs can be in the same directory's configs in /var/etc/ and the cam's /usr/local/bin/
a few things, each CCcam needs a differend CardReader but the CCcam,s can share the same *** files.
when you want to use moer Cccams then 3 you have to change some lines.

chmod 755 the scripts

to start the cam's from reboot from the pc ,set the line in /etc/rc.local :
/var/script/MoreCCcamstart.sh
and to use the configupdate script . you better do like this first stop the cam's compleet!
then do configupdate then start the cam's again and use thise times because of the check script.
crontab -e
56 03 * * * /var/script/MoreCCcamstop.sh
57 03 * * * /var/script/MoreConfigUpdate.sh
58 03 * * * /var/script/MoreCCcamstart.sh
*/5 * * * * /var/script/MoreCCcamCheck.sh

************************************************** ****************************

################################################## #################################################
script name MoreCCcamCheck.sh
################################################## #################################################
#!/bin/sh
#Script to check if the CCcam's are running.
#Script is written by Youknowhoo.
process=`ps auxwww | grep CCcam_1.x86 | grep -v grep | awk '{print $1}'`
if [ -z "$process" ]; then
echo "Couldn't find CCcam_1.x86 running.removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown root /tmp/.CCcam.nodeid
rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_1.x86 -C /var/etc/CCcam_1.cfg
else echo "CCcam_1.x86 is still OK!" >> /var/cccamlog/cccam.check
fi
process=`ps auxwww | grep CCcam_2.x86 | grep -v grep | awk '{print $1}'`
if [ -z "$process" ]; then
echo "Couldn't find CCcam_2.x86 running.removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown root /tmp/.CCcam.nodeid
rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_2.x86 -C /var/etc/CCcam_2.cfg
else echo "CCcam_2.x86 is still OK!" >> /var/cccamlog/cccam.check
fi
process=`ps auxwww | grep CCcam_3.x86 | grep -v grep | awk '{print $1}'`
if [ -z "$process" ]; then
echo "Couldn't find CCcam_3.x86 running.removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown root /tmp/.CCcam.nodeid
rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_3.x86 -C /var/etc/CCcam_3.cfg
else echo "CCcam_3.x86 is still OK!" >> /var/cccamlog/cccam.check
fi
exit


################################################## #################################################
script name MoreCCcamstart.sh
################################################## #################################################

#!/bin/bash
#Script to start more then one CCcam's with different nodeid
#Script is written by Youknowhoo.
echo "Starting first CCcam"
/emu/cccam/CCcam_1.x86 -C /var/etc/CCcam_1.cfg
echo "chown owner nodeid"
chown root /tmp/.CCcam.nodeid
echo "Removing nodeid and starting second CCcam"
rm /tmp/.CCcam.nodeid && /emu/cccam/CCcam_2.x86 -C /var/etc/CCcam_2.cfg
echo "chown owner nodeid"
chown root /tmp/.CCcam.nodeid
echo "Removing nodeid and starting third CCcam"
rm /tmp/.CCcam.nodeid && /emu/cccam/CCcam_3.x86 -C /var/etc/CCcam_3.cfg
exit



################################################## #################################################
script name MoreCCcamstop
################################################## #################################################

#!/bin/bash
#Script to stop all CCcam that are running.
#Script written by Youknowhoo
echo "stop first CCcam server"
killall CCcam_1.x86
echo "stop second CCcam server"
killall CCcam_2.x86
echo "stop third CCcam server"
killall CCcam_3.x86
exit


################################################## #################################################
script name MoreConfigUpdate.sh
################################################## #################################################

#!/bin/bash
#Script to process new config and backup old one
#Script designed and written by CC_Share
SOURCE=/var/config
TARGET=/var/etc
FILE=CCcam_1.cfg
BACKUPDIR=/var/backup
CONFIGOLD=CCcam_1.old
if test -f $SOURCE/$FILE ; then
echo "New Config Present"
if test -d $BACKUPDIR ; then
if test -f $BACKUPDIR/$CONFIGOLD ; then
echo "Removing OLD config file from backup directory"
rm $BACKUPDIR/$CONFIGOLD
else
echo "No OLD config to remove."
fi
if test -f $BACKUPDIR/$FILE ; then
echo "Renaming Backup to old config"
cp $BACKUPDIR/$FILE $BACKUPDIR/$CONFIGOLD
rm $BACKUPDIR/$FILE
else
echo "No Backupfile present yet"
fi
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
rm $TARGET/$FILE
else
echo "No Original Config File Present!?!?"
fi
else
echo "Backup directory does not exist."
echo "making new directory"
mkdir $BACKUPDIR
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
else
echo "No Original Config File Present!?!?"
fi
fi
echo "Moving New config file to "$TARGET
cp $SOURCE/$FILE $TARGET
rm $SOURCE/$FILE
else
echo "No New Config present, Nothing to process"
fi
SOURCE=/var/config
TARGET=/var/etc
FILE=CCcam_2.cfg
BACKUPDIR=/var/backup
CONFIGOLD=CCcam_2.old
if test -f $SOURCE/$FILE ; then
echo "New Config Present"
if test -d $BACKUPDIR ; then
if test -f $BACKUPDIR/$CONFIGOLD ; then
echo "Removing OLD config file from backup directory"
rm $BACKUPDIR/$CONFIGOLD
else
echo "No OLD config to remove."
fi
if test -f $BACKUPDIR/$FILE ; then
echo "Renaming Backup to old config"
cp $BACKUPDIR/$FILE $BACKUPDIR/$CONFIGOLD
rm $BACKUPDIR/$FILE
else
echo "No Backupfile present yet"
fi
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
rm $TARGET/$FILE
else
echo "No Original Config File Present!?!?"
fi
else
echo "Backup directory does not exist."
echo "making new directory"
mkdir $BACKUPDIR
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
else
echo "No Original Config File Present!?!?"
fi
fi
echo "Moving New config file to "$TARGET
cp $SOURCE/$FILE $TARGET
rm $SOURCE/$FILE
else
echo "No New Config present, Nothing to process"
fi
SOURCE=/var/config
TARGET=/var/etc
FILE=CCcam_3.cfg
BACKUPDIR=/var/backup
CONFIGOLD=CCcam_3.old
if test -f $SOURCE/$FILE ; then
echo "New Config Present"
if test -d $BACKUPDIR ; then
if test -f $BACKUPDIR/$CONFIGOLD ; then
echo "Removing OLD config file from backup directory"
rm $BACKUPDIR/$CONFIGOLD
else
echo "No OLD config to remove."
fi
if test -f $BACKUPDIR/$FILE ; then
echo "Renaming Backup to old config"
cp $BACKUPDIR/$FILE $BACKUPDIR/$CONFIGOLD
rm $BACKUPDIR/$FILE
else
echo "No Backupfile present yet"
fi
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
rm $TARGET/$FILE
else
echo "No Original Config File Present!?!?"
fi
else
echo "Backup directory does not exist."
echo "making new directory"
mkdir $BACKUPDIR
if test -f $TARGET/$FILE ; then
echo "Copying Original config to Backup directory"
cp $TARGET/$FILE $BACKUPDIR
else
echo "No Original Config File Present!?!?"
fi
fi
echo "Moving New config file to "$TARGET
cp $SOURCE/$FILE $TARGET
rm $SOURCE/$FILE
else
echo "No New Config present, Nothing to process"
fi
exit



rc.local:

/bin/cccam start &
/emu/script/runonce.sh &
/var/script/MoreCCcamstart.sh &
exit 0
 

prcunha

GF Ouro
Membro Inactivo
Entrou
Out 29, 2012
Mensagens
1,552
Gostos Recebidos
0
Mais um grande post amigo.
Obrigado!

Continuação de bom trabalho ;)

Abraço
 

nansediz

GF Ouro
Entrou
Abr 20, 2011
Mensagens
652
Gostos Recebidos
1
Boas,
Amigo @obelix699 ou outro amigo qualquer, será que poderiam explicar como meter isto numa VPS?
Os scripts até entendo, agora o rc.local é que me está a deixar aqui confuso, não vejo o cccam para meter em bin, nem o runonce para meter em emu/script.

1 abraço nansediz
 
Topo