<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="Oscam on WNR3500L">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2010-12-28 11:02<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
Oscam on WNR3500L


This is is a step-by-step guide on how to install Oscam on your Netgear WNR3500L router with an omnikey card. This guide should also work on other routers that are built on openwrt (dd-wrt, tomato etc.).



This guide will (hopefully) be easy to understand, even for those of you that havent used Linux before. I assume you know general things like how to create a new file or change dir.



Preparations

First, install your router with a firmware based on openwrt. Personally i like tomato over dd-wrt, here is a guide on how to install tomato on the wnr3500l router. Currently im using tomato-K26USB-1.28.9050MIPSR2-beta20-vpn3.6 on my router.



You should get a usb-hub since you're going to install some software on the router. You'll also need a memory stick and a cardreader too. A good quality hub should work fine (d-link and such).



Enable ssh access in the web interface (administration -&gt; access restrictions). If you're on Linux, open a terminal and ssh to the box. If not use a terminal emulator like putty. Default user\pw is root\admin.



Now you need a optware package, I'm using Valerakvb optware package, to install it ether become a member there or read the instructions below:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
3:
                        

                        
                        cd /tmp
wget http://www.xtremecoders.org/optware/valera124.sh
sh valera124.sh
                        

                    
                
            
            

            

        
    





Just follow the on screen instructions and wait a few minutes.



Now the http port for your router should have changed to 8080, you dont have to do anything there for the time being. 



Install dependencies

Oscam depends on a few packages, thE_29 has been so kind to make ipkg packages of all dependencies we need Binaries Asus WL500gP OlegFirmware (mipsel)



Install pcsc-lite and ccid

Copy the links from the thread above and download them with wget:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
                        

                        
                        wget http://oscam.ump2002.net/board/attachment.php?attachmentid=2736
wget http://oscam.ump2002.net/board/attachment.php?attachmentid=2737
                        

                    
                
            
            

            

        
    



Unpack the files with tar:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
                        

                        
                        tar -xf attachment.php?attachmentid=2736
tar -xf attachment.php?attachmentid=2737
                        

                    
                
            
            

            

        
    



Install the ipkg files with ipkg:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
                        

                        
                        ipkg install pcsc-lite_164_thE29.ipk
ipkg install ccid_1400_thE29.ipk
                        

                    
                
            
            

            

        
    





Install newer version of libusb

Since the newer versions of oscam require libusb after version 1: libusb-1.0.8.tar.bz2. We need to download the source and compile it on the router. Since tar that comes with the optware doesnt work that well you need to unpack the files and scp them over to the router. Before you can compile anything you need a few compilers. You should get all you need from the package &quot;buildroot&quot;:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
                        

                        
                        ipkg remove libiconv 
ipkg install buildroot make
                        

                    
                
            
            

            

        
    



You have to remove libiconv since it is included in buildroot, installing buildroot takes some time (5min). This is normal.

Now enter the libusb-1.0.8 dir and run these comands:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
3:
                        

                        
                        chmod -R +x *
./configure --prefix=/opt
make &amp;&amp; make install
                        

                    
                
            
            

            

        
    



Since you've transferred the files with scp all permissions have been removed... Since some files need to be executed, you need to set execute permissions on them in order for it to work.





OSCAM

Get the latest package from the_29:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
3:
                        

                        
                        wget http://oscam.ump2002.net/board/attachment.php?attachmentid=2423
tar -xvf attachment.php?attachmentid\=2423
ipkg install oscam-0.99.4svn2758-mon-oleg-thE29.ipk
                        

                    
                
            
            

            

        
    



Or cross compile one yourself.



Folder structure, config and init script

I like having my own folders on the router for cardsharing so i make a new folder in /opt that i call &quot;cs&quot;:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
3:
4:
5:
                        

                        
                        mkdir /opt/cs
mkdir /opt/cs/oscam
mkdir /opt/cs/oscam/conf
mkdir /opt/cs/oscam/bin
mkdir /opt/cs/oscam/log
                        

                    
                
            
            

            

        
    



Make a few config files:

oscam.conf


    
        
            quote:

        
        
            

            [global]

            serverip = 192.168.1.1

            logfile = /opt/cs/oscam/log/oscam.log

            disablelog = 1

            disableuserfile = 0

            usrfileflag = 0

            clienttimeout = 5000

            fallbacktimeout = 2500

            clientmaxidle = 120

            bindwait = 120

            netprio = 0

            clientdyndns = 0

            resolvedelay = 30

            unlockparental = 0

            nice = 99

            serialreadertimeout = 1500

            maxlogsize = 10

            waitforcards = 0

            preferlocalcards = 1

            saveinithistory = 1

            readerrestartseconds = 5

            readerautoloadbalance = 1

            readerautoloadbalance_save = 0

            

            [webif]

            httpport = 49200

            httpuser = oscam

            httppwd = password

            httprefresh = 5

            httpallowed = 192.168.0.0-192.168.255.255

        
    



oscam.server


    
        
            quote:

        
        
            

            [reader]

            label = omnikey

            enable = 1

            protocol = pcsc

            device = 0

            key = 0102030405060708091011121314

            services =

            caid = 0B00&amp;FFFF (feks)

            ident =

            group = 1

            emmcache = 1,1,2

            ecmcache = 1

            blockemm-g = 1

            lb_weight = 100

        
    



Save them all in /opt/cs/oscam/conf/

Since we are going to use a init script we need to move the oscam binary from /opt/bin/ to /opt/cs/oscam/bin/:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
                        

                        
                        mv /opt/bin/oscam /opt/cs/oscam/bin/
                        

                    
                
            
            

            

        
    



Create a new init file in /opt/bin/:

oscam


    
        
            quote:

        
        
            

            #!/bin/sh

            #Scriptfile for starting and stopping oscam

            #Scriptwriting done by CC_Share

            #For support and more info visit http://www.eurocardsharing.com

            

            #Setting variables

            CAMNAME=&quot;Oscam Server&quot;

            CAMDIR=&quot;/opt/cs/oscam/bin&quot;

            CONFDIR=&quot;/opt/cs/oscam/conf&quot;

            LOGDIR=&quot;/opt/cs/oscam/log&quot;

            CAM=&quot;oscam&quot;

            # end

            

            # Checking for pid file existance

            if [ ! -f $CAMDIR/oscam.pid ]

            then

            echo &quot;No pidfile exists, Creating PID for oscam&quot;

            else

            rm $CAMDIR/oscam.pid

            echo &quot;Pidfile allready found, Removing old pidfile&quot;

            fi

            

            pidof $CAM &gt; $CAMDIR/oscam.pid

            PID=$(exec cat $CAMDIR/oscam.pid)

            

            # This method starts oscam

            start_cam ()

            {

            $CAMDIR/$CAM -b -c $CONFDIR &amp;

            sleep 5

            }

            # This method stops oscam

            stop_cam ()

            {

            kill -9 $PID

            sleep 5

            }

            case &quot;$1&quot; in

            start)

            echo &quot;[SCRIPT] $1: $CAMNAME&quot;

            ##Check if cam is runing

            if ps | grep -v grep | grep -v start | grep $CAM &gt; /dev/null

            then

            echo &quot;$CAM runing, stop it first!&quot;

            else

            start_cam

            fi

            ;;

            stop)

            echo &quot;[SCRIPT] $1: $CAMNAME&quot;

            stop_cam

            ;;

            restart)

            echo &quot;Restarting $CAMNAME&quot;

            stop_cam

            start_cam

            ;;

            *)

            &quot;$0&quot; stop

            exit 1

            ;;

            esac

            exit 0

        
    



Chmod it so you can execute it:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
                        

                        
                        chmod +x /opt/bin/oscam
                        

                    
                
            
            

            

        
    



Now you should be able to start, restart and stop oscam easily from the terminal:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
                        

                        
                        oscam start|restart|stop
                        

                    
                
            
            

            

        
    





Oscam restart &quot;bug&quot;

For some reason, i cant use the &quot;restart&quot; option, i have to stop and start it manually. Therefore i made a small script:


    
        
            quote:

        
        
            

            #!/bin/sh

            /opt/bin/oscam stop

            sleep 5

            /opt/bin/oscam start

            exit 0

        
    



I call this file &quot;start.sh&quot; and save it in /opt/bin/. Remember to chmod it:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
                        

                        
                        chmod +x /opt/bin/start.sh
                        

                    
                
            
            

            

        
    



When you want to restart oscam, just wrote &quot;start.sh&quot; and it should restart. 

A cool feature you can use this too, is using the button on the front to call these commands. Go to &quot;administration/Button\LED&quot; and set &quot;for 0-2 sec&quot; to &quot;run custom script&quot;. And write the script above.



Automatic startup

I assume you want the best uptime you can get, so I assume you would like having oscam starting up on each boot. The easiest way to do this is by using the web interface for the router and adding it to the init file (administration -&gt; scripts). Add this at the end of the file:


    
        
            

            
            
                
                    
                        code:

                    
                    
                        
                        1:
2:
3:
                        

                        
                        sleep 60
/opt/bin/start.sh  &amp;
exit 0
                        

                    
                
            
            

            

        
    



For some reason oscam doesn't work if you start it before some other service, thats why I use &quot;sleep 60&quot;.



Port forward

If you want to get acces to oscam from the outside you need to open the ports in the firewal.

Go to Administration -&gt; Scripts and choose Firewall and add the line:

iptables -A INPUT -p tcp --dport [port] -d [routers ip] -j ACCEPT

Change the [port] and [routers ip] to whatever the port and ip for your router is.

You would have to add the port forward as usual too in the &quot;Port forwarding&quot; tab.



Last words

What you do now is up to you, the configs would need changing to meet your needs (what card you have, ident etc.) and you have to setup users and choose what kind of server you're going to use (oscam supports cccam, newcamd+++). See the documentation or use the web interface (port 4200, oscam\password) to add users and configure.

Thanks to the_29 for ipkg packages and CC_Share for init script
</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
