How to: Oscam stop/start script + anti-crash monitor

There are 13 replies in this Thread which was already clicked 17,177 times. The last Post () by s3n0.

  • Hello Linux lovers


    I decided to write a small tutorial and show you my method of starting and stopping the Oscam in my Linux. And also a script that will keep it alive in case it crashes or shows one of 2 known errors (ins_40 and deadlock).
    You are free to change the script and improve it. I would be glad to implement some new stuff to it. I am using this method for long time and it works great for me!!
    Paths and file names are used as sample only. You can change it.
    This was tested on Debian Linux, but it should work on others too.



    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:


    * 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:


    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!!!

  • hi, i have just succesfully install this script and its running very very good.the only thing i like to know as my /var/log/oscam.log file getting bigger and bigger which i d,nt like to.
    could you please advice me how can solve this problem if possible?

    • Official Post

    hi, i have just succesfully install this script and its running very very good.the only thing i like to know as my /var/log/oscam.log file getting bigger and bigger which i d,nt like to.
    could you please advice me how can solve this problem if possible?


    The way i do this & much more is with webmin


    Installing Webmin On Your Debian Server


    Tutorial - Installing Webmin On Ubuntu Server



    Once installed you can choose which logs & how often you would like them deleted




    If you need help with webmin please open a new thread so this one sticks to topic.

  • My script has nothing to do with size of Oscam.log!! It is only reading the log and not writing to it.
    However, there is simple solution for your problem. Edit your oscam.conf file and limit the maximum size of the log:

    Code
    maxlogsize = kbytes


    So if you want to limit maximum size of the log to 512 Kilobytes, you should write this line to oscam.conf:

    Code
    maxlogsize = 512


    Enjoy!

  • Hello, instead of restart and everything, I'd like to create a script to reload only its config file (oscam.server) so that I can launch it as a script or I can create a cron.

    Is it possible to do that?

    Hello.


    Why didn't you open a separate TOPIC ?

    This discussion thread is about a different problem !


    What exactly do you mean by reloading "oscam.server" ? Do you mean reload all readers - restart them ? For this, there was a SIGHUP signal for the oscam process, but there was always a problem with it and I don't know if it still works: http://www.streamboard.tv/oscam/ticket/498

    killall -SIGHUP oscam or killall -HUP oscam


    Next, it would be necessary to add the following entries to the "oscam.conf" file (you only care about "reload_readers", so just try to add this one item there):

    Code
    reload_useraccounts           = 1
    reload_readers                = 1
    reload_provid                 = 1
    reload_services_ids           = 1
    reload_tier_ids               = 1
    reload_fakecws                = 1
    reload_ac_stat                = 1
    reload_log                    = 1

    Depending on what you need, you could theoretically also use an Oscam-Webif call with the "wget" command.

    - to reload readers with helping of the OscamWebif:

    wget -q -O - "http://loginname:password@127.0.0.1:8888/readers.html?action=reloadreaders"

    - example for CRON (scheduled every 10 days, at 06:00), for Entitlements refreshment with Oscam-Webif:

    0 6 */10 * *         /usr/bin/wget -q -O - "http://loginname:password@127.0.0.1:8888/readers.html?action=reread&label=reader_sci0"



    Otherwise, if anyone is interested, I also modified my starting bash script (on my Github you will find this script "/etc/init.d/softcam" in the basic version, without modifying auto-restart on crash). I edited this script for a friend esuo2 . The script runs in the background to test if the Oscam crashes, and if so, I'll start the oscam process again. The "fInfiniteLoop()" function runs continuously and verifies every 5 seconds that a process called "oscam" is running.


    I don't understand people who need autorestart when crashing Oscam, because Oscam really can't fall or freeze - if that happens it's bad and the problem needs to be solved!

  • After a few tries, where it seemed that the command wget managed to reload the readers, I must say that, although it actually does it, after a few minutes the oscam stops working.

    This happens either launching it as a script from the script panel, or by the Cron Manager.

    The idea of simply reload the readers is exactly what I need, because it's not a problem of testing if it's running or not. As you said, oscam never stops working.

    I simply need to reload readers after another script updates them ;)

    Any other solution?

  • I have this entry in my crontab:

    Code
    # refresh entitlements via Oscam-Webif
    0 6 */10 * *      /usr/bin/wget -q -O - "http://yourlogin:yourpassword@127.0.0.1:8888/readers.html?action=reread&label=reader_sci0"

    Everything works as it should. No freezing. No problems.


    Which set-top box do you own ? Which Enigma do you have installed ?


    I don't know what it means to you "reload readers / one reader". You have to write for what purpose you want to do a "reload". It is possible that this can be solved by a completely different method.


    Otherwise, I guess.


    Do an automatic restart of the whole Oscam. Or I really don't know what you need. Do you want to edit the oscam.server file for your Oscam, and then you want to apply the changes just by restarting a specific Oscam reader ? If so, wouldn't it be easier to restart the entire Oscam completely ? However, this depends on how many users are connected to the Oscam server. It is also important for what purpose, how often, why, you are changing the contents of "oscam.server". However, this time just guess what you probably want to achieve :). I still don't know what you need, sorry.

  • I have a VU+Solo4K equipped by OBH 4.3.

    Actually I had already wrote my need, in the last line of my previous post: "I simply need to reload readers after another script updates them".

    It means that I do a renew of the file oscam.server which rewrites it and changes all the [reader] sections.

    So, at the end of this process, I need to either restart Oscam or re-read ALL the cccam readers. This second options would be preferable, in my view.

    So, oscam is used only as a local reader and for only one user.


    I noticed in your line (where, obviously I put my data, that there it end by

    ...reader_sci0

    It refers to my slots, I suppose.

    My two slots for smartcards are both used but oscam is used also with ccam readers.


    Using your line actually re-reads the cccam readers but, after some minutes, oscam stops (and you can see that from the webinterface or by the fact the channels it manages stop working.

  • If you do not mind restarting the Oscam server by your connected clients who are connected to you, then use a simple Oscam restart. This is the simplest and most reliable. Find out which softcam script controls your Oscam and use this script.


    Theoretically, you can find auto-start scripts for softcams as follows:

    find /etc/init.d -name "*cam*"


    Then, for example, restart the oscam using the script:

    /etc/init.d/softcam restart

    ... or ...

    /etc/init.d/softcam.oscam restart


    If that doesn't work, you can also try calling the script directly through Bash / Sh (Shell):

    sh /etc/init.d/softcam restart

  • My oscam resides in /usr/bin and I have already tried the

    oscam restart

    command as my first attempt. It produces the error

    sh: pzapit: command not found

    then gets stuck (without having done anything).


    That's why I was looking for a re-reading of oscam.server and its readers.

  • In this case, you probably have an inappropriate script. Where does your Oscam come from ? From some softcam feed ? Or is it a manual installation procedure for Oscam ?


    What code does your softcam script contain ? Probably there is a mistake. Restarting the softcam must work !


    To use this manual installation procedure: Tutorial : How to install softcam (OSCam/CCCam) manually, if you hate ipk packages


    Or simply overwrite your current softcam script, my script (after downloading it as described in the manual installation procedure), and then customize the script to suit your needs (for example, the argument "-c" to determine the path to the Oscam configuration directory).

OSCam Support Forum

Configs, discussion, downloads and guides for OSCam Softcam.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!