Script to restart 1 of 2 readers on no entitelments.

There are 18 replies in this Thread which was already clicked 8,662 times. The last Post () by s3n0.

  • Hello All.


    I need a script that restarts a internal reader on no entitlements. I need this because one of my readers needs to be restarted a couple of times after restart of oscam, to read the entitlements. The other reader works without any problems (both are internal), so i do not want to restart oscam, but only the reader that does not work.
    Is this even possible? If yes, can anyone give me a push in the right direction, to where i can read about it, and try to make the script. I have tried to search high and low, but I do not seem to find anything on reader restart, only oscam restart.


    Thanks in advance

  • I do not think it can restart a single reader without restarting oscam


    "... one of my readers needs to be restarted a couple of times after restart of oscam, to read the entitlements" - can you explain more

    together we grow - ferdi

  • I believe it can, if i go the webif way. My thought was somthing like this:

  • I finally succeeded! If anyone else should be interested this is how:


    Webif must be activated in oscam.confand running.


    install curl via opkg with: opkg install curl


    Copy this script into /usr/script/, and set your box to run the script as offen as you like.


    #!/bin/sh
    while [ $(curl --digest -u'user:pass" "http://127.0.0.1:port/entitlements.html?label=Upper" | grep -c "tier") -lt 2 ]
    do
    curl --digest -u"user:pass" "http://127.0.0.1:port/status.html?action=restart&label=reader"
    sleep 65
    done
    echo "reader ok"


    Where user, pass and port is as configured in oscam.conf.
    Reader can be either upper or lower.
    Remember to grant access to 127.0.0.1 in oscam.conf

    Edited once, last by apebk ().

  • wafi villa :


    Instead of repeating the post, you'd better write what exactly doesn't work for you.


    /// EDIT :


    Improved previous script, no need to use curl (only wget will be used):



    Of course, this shell-script is not necessary at all if you use CRON - system scheduler. Just add a configuration line to CRON config-file:


    * * * * *       if [ $(/usr/bin/wget -qO- "http://USER:PASS@127.0.0.1:PORT/entitlements.html?label=YOUR_READER_LABEL" | grep -c "tier") -gt 0 ]; then /usr/bin/wget -qO- "http://USER:PASS@127.0.0.1:PORT/status.html?action=restart&label=YOUR_READER_LABEL" > /dev/null 2>&1; fi


    Don't forget to fill (to replace) the USER, PASS and PORT values for your Oscam-Webif !


    Or here is another example, a ready-made shell script that runs in the background and can run automatically with the set-top box via the init.d system in RunLevel3 (applies to Enigma2 set-top boxes):

    e2scripts/oscamrr at master · s3n0/e2scripts
    some helpful scripts (Python or Shell) for Enigma2 - e2scripts/oscamrr at master · s3n0/e2scripts
    github.com
  • HI


    Sorry I don't speak English well
    Thank you for your reply and interest
    I mean this script is it still working



    #!/bin/bash


    ###################################

    #### A simple endless shell-script that restarts the Oscam reader in case there are no "Tiers" in the "Entitlements" data.

    #### Original source: Script to restart 1 of 2 readers on no entitelments.

    #### Example of running the shell-script in the background: /bin/bash /usr/script/this_script_name.sh &

    ###################################


    USERNAME="a"

    PASSWORD="b"

    PORT="8888"

    OSCAM_WEBIF="http://${USERNAME}:${PASSWORD}@127.0.0.1:${PORT}" # if no password used: OSCAM_WEBIF="http://127.0.0.1:${PORT}"

    OSCAM_READER="reader_sci0"


    trap 'exit' INT TERM ERR

    trap 'kill 0' EXIT


    while true; do

    [ $(wget -qO- "${OSCAM_WEBIF}/entitlements.html?label=${OSCAM_READER}" | grep -c "tier") -gt 0 ] && wget -qO- "${OSCAM_WEBIF}/status.html?action=restart&label=${OSCAM_READER}" > /dev/null 2>&1 # restart the specific card reader

    # # # # # # # # # # # # # # # # # # # # # # # # # /readers.html?action=reread&label=${OSCAM_READER}" > /dev/null 2>&1 # re-read entitlements

    sleep 65

    done


    exit

  • Why wouldn't it work ? Try it and you'll see :-).


    But that's a bit more complicated. A "shell script" is not enough, so to speak. You have to be able to run it, apply it, leave it running in the resident background of a Linux system... or something similar. It is not enough to have a shell-script alone.


    Or write what you want to achieve exactly.

  • Thanks again for your interest

    I have two VU+ ZERO 4K devices with two OSCAM cards and two Conex cards and I want a script that will restart the OSCAM reader at a specific time

    Edited once, last by slibya ().

  • So in that case it depends on the type of encoding system of the card.


    Some decoding cards in the card reader require receiving some EMM packets for their functionality. Usually this needs to be done on the softcam servers so that they are ready for ECM decoding after the Oscam restart.


    I did this for the IRDETO coding system. This is a softcam shell-script for "init.d", which is modified so that after every Oscam-restart, the tuner is activated for a while with some preset satellite channel and then, after a few seconds, the tuner deactivates / turns off again. For this purpose that I describe, you need an "init.d" shell-script named as:


    "softcam (+ zap channel each time when softcam was started)"


    ... and then rename it as you need, according to your current "softcam" script in the folder " init.d".


    Of course... don't forget to edit this script of mine so that the name of the binary file fits... or any other details in the script.


    If you just want to restart Oscam, just add a simple line to the CRON scheduler and you don't need any modified softcam script (for example):

    Code
    # restart the Oscam , every night, at 04:30
    30 04 * * *        /bin/bash /etc/init.d/softcam restart


    However, keep in mind, as I mentioned the exemplary IRDETO coding, which I know a little, that there is a need to always accept EMM packets after the Oscam restart - so that the IRDETO card starts working.


    ------------------------------------


    If you're looking for what was said in the original question, you're probably looking for this:

    Code
    # refresh entitlements via Oscam Webif, every 9 days, at 06:00
    00 06 */9 * *     /usr/bin/wget -q -O - "http://USER_LOGIN:USER_PASSWORD@127.0.0.1:8888/readers.html?action=reread&label=OSCAM_READER_NAME" > /dev/null 2> &1

    (a note: by this method, entitlements are only refreshed inside the Oscam... not written to the card... the EMM packets must take care of writing entitlementmenets to card)

Your resource for OSCam softcam

Find configs, downloads, tutorials, and support for setting up and optimizing this open-source card server with wide protocol compatibility. Master the versatile OSCam softcam. Access support, configs, tutorials, and downloads for open-source card sharing and multi-protocol server management.

Participate now!

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