CCcam.x86 -C configfile1 CCcam.x86 -C configfile2
hello all,
i have written/modify a check script for all the CCcam's there are running,
to run every */5 * * * * (ore what time you want)
in crontab for when One of the CCcam should stops.
*/5 * * * * /var/script/MoreCCcamCheck.sh
it checks all CCcam, in this case there are 3 running CCcam's
if you have more or less CCcam
just modify by add or remove a last part ( it shown i blue)
and you may have to change the file/folder/directory (this is my setup)
it writes in /var/cccamlog a cccam.check if CCcam is oke ore when it is restarted
this script works on Ubuntu (maybe someone can test it on Debian, i think
it will work)
I have written this script for the ones who want to use it
feel free to modefy the script, it is finally or hobby to share.
xxxxxx = inlogname from distro
if you want date and time in log ad the red lines.
then you can see when it has restarted and what CCcam it was.
--------------------------------------------------------------------------
MoreCCcamCheck.sh
--------------------------------------------------------------------------
#!/bin/sh
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. Show user Nodeid then removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown xxxxxxx /tmp/.CCcam.nodeid
nohup 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. Show user Nodeid then removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown xxxxxxx /tmp/.CCcam.nodeid
nohup 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. Show user Nodeid then removing nodeid and Restarting CCcam Server" >> /var/cccamlog/cccam.check
echo && date >> /var/cccamlog/cccam.check
chown xxxxxxx /tmp/.CCcam.nodeid
nohup 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
for all who like the post feel free to hit the thanks button.
youknowhoo
(10-October-2009 20:09)
and a config update script it is written by CC_Share but i modified it a little.
the script works great.
you can use it also for 1 config as i do, you only have to cut the blue part.
and rename the FILE & CONFIGOLD
--------------------------------------------------------------------------
MoreConfigUpdate.sh
--------------------------------------------------------------------------
#!/bin/bash
#Script to process new config and backup old one
#Script designed and written by CC_Share and modified by Youknowhoo
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
name startscript: MoreCCcamstart.sh
--------------------------------------------------------------------------
#!/bin/bash
#Script to start more then one CCcam's with different nodeid
#Script is written by Youknowhoo.
echo "Starting first CCcam server"
/usr/local/bin/CCcam_1.x86 -C /var/etc/CCcam_1.cfg
echo "chown owner nodeid"
chown xxxxx /tmp/.CCcam.nodeid
echo "Removing nodeid and starting second CCcam server"
rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_2.x86 -C /var/etc/CCcam_2.cfg
echo "chown owner nodeid"
chown xxxxx /tmp/.CCcam.nodeid
echo "Removing nodeid and starting third CCcam server"
rm /tmp/.CCcam.nodeid && /usr/local/bin/CCcam_3.x86 -C /var/etc/CCcam_3.cfg
xxxxx = user/inlog name from the linux distro
--------------------------------------------------------------------------
name stopscript : MoreCCcamstop.sh
--------------------------------------------------------------------------
#!/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