记录我的一些生活写照、无聊的牢骚、内心世界的活动 注册 | 登陆

Oscam on WNR3500L

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 -> 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 "buildroot":
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 && 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 "cs":
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&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="Oscam Server"
CAMDIR="/opt/cs/oscam/bin"
CONFDIR="/opt/cs/oscam/conf"
LOGDIR="/opt/cs/oscam/log"
CAM="oscam"
# end

# Checking for pid file existance
if [ ! -f $CAMDIR/oscam.pid ]
then
echo "No pidfile exists, Creating PID for oscam"
else
rm $CAMDIR/oscam.pid
echo "Pidfile allready found, Removing old pidfile"
fi

pidof $CAM > $CAMDIR/oscam.pid
PID=$(exec cat $CAMDIR/oscam.pid)

# This method starts oscam
start_cam ()
{
$CAMDIR/$CAM -b -c $CONFDIR &
sleep 5
}
# This method stops oscam
stop_cam ()
{
kill -9 $PID
sleep 5
}
case "$1" in
start)
echo "[SCRIPT] $1: $CAMNAME"
##Check if cam is runing
if ps | grep -v grep | grep -v start | grep $CAM > /dev/null
then
echo "$CAM runing, stop it first!"
else
start_cam
fi
;;
stop)
echo "[SCRIPT] $1: $CAMNAME"
stop_cam
;;
restart)
echo "Restarting $CAMNAME"
stop_cam
start_cam
;;
*)
"$0" 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 "bug"
For some reason, i cant use the "restart" 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 "start.sh" 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 "start.sh" 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 "administration/Button\LED" and set "for 0-2 sec" to "run custom script". 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 -> scripts). Add this at the end of the file:
code:
1:
2:
3:
sleep 60
/opt/bin/start.sh  &
exit 0

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

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 -> 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 "Port forwarding" 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

« 上一篇 | 下一篇 »

发表评论

评论内容 (必填):