install oscam to raspbxPridané: 19.10.2016

Raspberry Pi and Oscam

Raspberry Pi and Oscam

 

I have recently acquired a couple of Raspberry Pi to play with, and I must say I am quite impressed with this cheap little device.

You can use it as a desktop, a small server, a media center and you also have GPIO interface to control external hardware, like sensors and motor drivers (like the Arduino but with much more processing power and memory).

The first experiment I did when I got my hands on the Raspberry was to compile and install Oscam so I could have a server with little energy consumption but still has the processing power required to sustain a large number of Oscam users and readers.

This post is the report of my experiment and will allow you to reproduce my steps.

 

This tutorial is organized in 4 steps :

Step 1 – Prepare an SD-Card with a Raspbian official image and boot your Raspberry for the first time.
Step 2 – Install the packages required to compile Oscam for the Raspberry.
Step 3 – Get the source, compile and install Oscam on the Raspberry.
Step 4 – Final tweaks on your new Oscam server.

So, before we start, you are going to need to download a few tools and the Raspberry Image.
Below is the list of tools I used, there are others but these ones worked for me.

Tools Required

Win32DiskImager – https://launchpad.net/win32-image-writer

This tool will be used to load the Raspbian Image into the SD-Card.

Putty – http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

This is an SSH and Telnet client which will be used to remotely access the Raspberry.

Filezilla FTP Client– http://filezilla-project.org/download.php?type=client

This is an FTP client that supports SFTP which will be used to send files to the Raspberry using the SFTP protocol.

Raspbian Image – http://www.raspberrypi.org/downloads

This is the Raspbian image which will be loaded into the SD Card (need a 2Gb card or higher).

 Ok, now that you have downloaded the tools, let´s get started.

Step 1 – Prepare an SD-Card with a Raspbian official image and boot your Raspberry for the first time.

There are several images for the Raspberry. On this tutorial we are using the official Raspbian image. It comes with alot of stuff you will not use on a dedicated Oscam server, like the X server and the LXDE Enviroment but we will use this image and not remove anything because you might want to use your raspberry for other stuff while running Oscam at the same time.

  1. Extract the Raspbian image you downloaded into a folder on the computer.
  2. Insert your SD Card on the computer card reader or an external card reader.
  3. Launch the Win32DiskImager and select the image you extracted (ex: 2012-09-18-wheezy-raspbian.img).
  4. Select the drive letter of the SD Card you want to flash.
  5. Click on “Write” and wait for the process to terminate.

There are many other ways to flash the image on the SD Card as you can see here.

Now that the image is flashed, it is time to insert the card into the Raspberry and connect the power, display and network cable.

Remember that the default login for this image is :

Username : pi
Password : raspberry

At the raspberry first boot you will see a configuration menu which will allow you to setup your system (this is the raspi-config tool which you can call at any time by using the “sudo raspi-config” command).

The only changes I made on this menu was the “expand_rootfs” option because I have an 8Gb SD-Card and wanted to use the full space (by default it uses just 2Gb) and I changed my password and the timezone to correct the date/time for my country and zone.

After setting your changes I advise you to restart your raspberry.

 

Now that you have installed your image on the Raspberry it is time to prepare the system for Oscam.
You will obviously need to type some commands to install the packages, you can do this by using a keyboard connected on one of the USB ports or you can do it remotely using SSH and I recommend the SSH method because you will be able to copy & paste commands which is very useful. In order to remotely access the Raspberry SSH server, it should be connected to the network and you need to know which IP address it has acquired from the DHCP server.

After booting the raspberry there will be a message on the console which says something like “My IP address is xxx.xxx.xxx.xxx”.
After logging into the raspberry you can also type “ifconfig” and you will see the network configuration for the eth0 device. The second line should be something like “inet addr: xxx.xxx.xxx.xxx”. That is the raspberry IP address.

Now that you know which IP address is being used by your raspberry :

  1. Launch putty.exe.
  2. Type the IP address of the raspberry in the Hostname field.
  3. Click on “Open“.
  4. Accept the certificate and login with the “pi/raspberry” account.

 

The first step of this tutorial is done.
You have successfully loaded an image into your raspberry and now have remote access to the system.

Step 2 – Install the packages required to compile Oscam for the Raspberry.

Now that you are logged into the system, you will install all the packages required to compile Oscam.

You can paste the following commands into Putty by clicking the right mouse button.

First, you will update the package repositories of the APT system.

sudo apt-get update

The sudo command is used when you need to do something that requires permissions of a superuser. We use it because the “pi” account is not a superuser and system level operations like installing packages need a superuser account.

Now, let´s install the packages for compiling Oscam.

sudo apt-get install subversion cmake build-essential libssl-dev libpcsclite1 libpcsclite-dev dialog

If you are using USB smartcard readers, you will need to compile libusb.

Go to your home directory.

cd ~

Download libusb sources from sourceforge.

wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.9/libusb-1.0.9.tar.bz2

Extract the sources.

tar xjvf libusb-1.0.9.tar.bz2

Compile libusb and install.

cd libusb-1.0.9
./configure
make
sudo make install

Back to home directory.

cd ~

All packages required for compiling Oscam have been installed.

Step 3 – Get the source, compile and install Oscam on the Raspberry.

Now that you have all the required tools to compile Oscam, let´s get the source from the SVN repository.

svn checkout http://www.streamboard.tv/svn/oscam/trunk oscam-svn

Get inside the sources folder.

cd oscam-svn

Make the folder where the compiled binaries will be created.

mkdir build

Get inside the folder.

cd build

Prepare the build using cmake.

cmake ..

Compile Oscam

make

Install Oscam

sudo make install

If everything went smooth without any errors, you should now have Oscam installed on your system.
The oscam binary should now be located at /usr/local/bin.

By default oscam will attempt to read the configuration files located at /usr/local/etc so we have to copy the files into it.

Let´s change the ownership of the configuration folder so you are able to upload files using the SFTP client using the pi account.

sudo chown pi.pi /usr/local/etc –R
  1. Launch Filezilla FTP Client
  2. Open the Site Manager and create a new site.
  3. Select protocol “SFTP – SSH File Transfer Protocol”.
  4. Select Logon Type “Normal”.
  5. Type your raspberry username and password and click “OK”.
  6. Navigate to /usr/local/etc folder and upload your oscam configuration files.

Note : If you don´t have any configuration files already created, check /home/pi/oscam-svn/Distribution/doc/example.

 

To test you new Oscam server, type

sudo oscam

Congratulations, you have successfully compiled and installed Oscam on your Raspberry.
If you want to learn how to setup oscam to start on boot and set a fixed IP address, check the next step.

Step 4 – Final tweaks on your new Oscam server.

On this step you will be able to set oscam like a daemon which will be started when the system boots, set a fixed IP address and update oscam to a newer version.

Updating Oscam to a newer revision.

Upgrading oscam to a newer revision is quite easy and you don´t have to do everything all over again.

You just need to update your svn copy from the repository and compile/install again.

cd ~/oscam-svn
svn update
cd build
sudo make install

Remember to restart oscam after installing the newer version.
Also, since you are using the trunk revisions of oscam, some things might be buggy and sometimes you need to revert to a previous revision.
You can do this by calling “svn update” with the -r parameter to specify a revision :

cd ~/oscam-svn
svn update -r 10656
cd build
sudo make install

Setting up a fixed IP address.

This is quite simple. You just need to edit a file and restart the interface.
Edit the network configuration file.

sudo nano /etc/network/interfaces

Find the line that reads “iface eth0 inet dhcp” and replace with the following lines.

iface eth0 inet static
address 192.168.1.130
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Replace the IP address to reflect your own network settings.
Now restart the network service.

sudo /etc/init.d/networking restart

If you are using SSH to edit the settings, you will be disconnected because you restarted the network.
You can now connect to the Raspberry using the new IP address.

Start Oscam with system boot.

To start Oscam automatically when your system boots is quite useful because if you have a power failure you make sure that Oscam will start when the power comes back and your system reboots.

To do this, we just need to copy a script to the /etc/init.d/ folder and set it´s runlevel.

Copy the following script and save it on your computer with the name “oscam”.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          Oscam
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Oscam init script
# Description:       Launch oscam at startup
### END INIT INFO
 
DAEMON=/usr/local/bin/oscam
DEAMON_OPTS="-b -r 2"
PIDFILE=/var/run/oscam.pid
 
test -x ${DAEMON} || exit 0
 
. /lib/lsb/init-functions
 
case "$1" in
    start)
	log_daemon_msg "Starting OScam"
	start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} -- ${DAEMON_OPTS}
	log_end_msg $?
    ;;
    stop)
	log_daemon_msg "Stopping OScam"
	start-stop-daemon --stop --exec ${DAEMON}
	log_end_msg $?
    ;;
    force-reload|restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/oscam {start|stop|restart|force-reload}"
    exit 1
    ;;
esac
 
exit 0

On putty type the commands :

sudo touch /etc/init.d/oscam
sudo chown pi.pi /etc/init.d/oscam

Open Filezilla and upload “oscam” file to “/etc/init.d”.

Type the command

sudo chmod 755 /etc/init.d/oscam

Now that you have the script and have setup the correct execute permissions, type :

sudo update-rc.d oscam defaults
 

Späť na zoznam článkov
Zatvoriť

K článku neboli pridané žiadne komentáre vložiť nový komentár

Copyright 2016 - 2017 © TVCentrum