Re: open pli
Yes I have always downloaded images set up with Oscam and Cccam already in the pannel mate so never really had a problem.
Here is a start stop and anti crash Oscam Script but It just went straight over my head might be a good Idea to use native oscam and set up some accounts like the lads suggested anyway, much better way then you can set up anti cascading and a service list etc
Step 1:
Put your oscam binary to this path and name it like this:
Code:
/emu/oscam/oscam.x86
And put your all config files to this same folder:
Code:
/emu/oscam
Don't forget to give 755 permissions to oscam.x86:
Code:
chmod 755 /emu/oscam/oscam.x86
Step 2:
Create a script that will easily control start/stop of your oscam and name it oscript. I am using vi as editor. You can use any editor you wish:
Code:
vi /emu/oscam/oscript
and then paste this text to the file:
Code:
#!/bin/sh
CAMNAME="Oscam Server"
# end
# This method starts Oscam
start_cam ()
{
pkill -9 oscam.x86
sleep 2
/emu/oscam/oscam.x86 -c /emu/oscam &
}
# This method stops Oscam
stop_cam ()
{
pkill -9 oscam.x86
}
case "$1" in
start)
echo "[SCRIPT] $1: $CAMNAME"
start_cam
;;
stop)
echo "[SCRIPT] $1: $CAMNAME"
stop_cam
;;
restart)
echo "Restaring $CAMNAME"
stop_cam
sleep 7
start_cam
;;
*)
"$0" stop
exit 1
;;
esac
exit 0
* I prefer to run kill command before starting the oscam. Just in case oscam is already running when you execute start command.
Don't forget to give 755 permissions to oscript:
Code:
chmod 755 /emu/oscam/oscript
Create symbolic link so you can easily use this script from any location:
Code:
ln /emu/oscam/oscript /bin/oscript
Now you can simply start, stop or restart oscam from any directory by simply typing:
Code:
oscript start
oscript stop
oscript restart
Step 3:
Now you need a script that will control your Oscam and keep it running all the time. Create the script and name it check_os:
Code:
vi /emu/oscam/check_os
Don't forget to give 755 permissions to check_os script:
Code:
chmod 755 /emu/oscam/check_os
and then paste this text to the file:
Code:
#!/bin/bash
if ! ps x |grep -v grep |grep -c /emu/oscam/oscam.x86 >/dev/null
then
oscript start
echo `date "+%d/%m/%y %R process was not working"` >> /var/log/oscam_restart_log
# This part above will check if there is NO oscam process running.
# And if this condition it truth, it will start it and write to log.
# Log entry will contain time stamp and reason of execution (process not working)
# If first condition in not truth (oscam was running), go further to next condition.
elif
tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null
then
oscript restart
echo `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam_restart_log
elif
tail -8 /var/log/oscam.log |grep -v grep |grep -c trylock >/dev/null
then
oscript restart
echo `date "+%d/%m/%y %R trylock error detected"` >> /var/log/oscam_restart_log
# Those 2 conditions will look for 2 common errors in Oscam: "ins40" and "trylock"
# If last 8 lines of your oscam.log contain any of those errors, it will restart oscam.
# Log entries will include the exact reason of restart.
# ins40 error is random error that will keep oscam running but no CWs returned.
# trylock is older error that appear if you use CCcam protocol in oscam.server
else
echo "ok"
# If oscam passes all conditions and all is OK, it will simply echo "ok"
fi
# ENJOY - supermariocs
As you can see in the text, my oscam log is located in /var/log directory.
This means that you need this line in your "oscam.config" file:
Code:
logfile = /var/log/oscam.log
Also, every restart by this script will be recorded in this file:
Code:
/var/log/oscam_restart_log
It will include time stamp and reason for restart so you can have trace of it.
Step 4:
Now you need a crontab entry that will run all the time in the background and check your oscam status. I prefer to run it every 15 minutes, but you can change it of course:
Code:
vi /etc/crontab
and add this line:
Code:
*/15 * * * * root /emu/oscam/check_os >/dev/null
Step 5:
Add this line to your startup file. In Debian it is "/etc/rc.local"
Code:
/bin/oscript start &
Step 6:
ENJOY!!!
Reply With Quote