Install SASC-NG

From Dolot
Jump to: navigation, search

Read the *old* tutorial here: Install Open-SASC-NG

The "previous" development version Open-SASC-NG is dead. The vdr fork, however, is still alive. This is the one we'll be using now.

If you want to install SASC-NG on something older than Ubuntu 11.10, browse this page's history

Ubuntu 11.10 problem: Linux kernel 3.0 has a few problems. You can install sasc-ng and run it using these instructions, but opening the capture device will freeze the program!

Contents

1 Introduction

SASC-NG is a so called "softcam". It's a piece of software which is able to decode satellite feeds.

This can be useful in multiple cases:

  • When your DVB-S(2) device does not have a CI
  • When you just don't want to buy a CI & CAM (since it is quite expensive)
  • When you want to share a card over multiple tuners in your system (Perfectly legal, although it may be a breach of contract with your provider)
  • When you want to participate in cardsharing over the internet (this is, err, less legal)

2 Preparation

2.1 Got root?

Installing everything is much easier when you're root.

sudo -s

2.2 Linux 3.x

There's a problem in Linux kernel versions higher than 2.6.38. You'll need to recompile your kernel with the appropriate patch. You can follow our Linux v3.0.4 guide, which is very easy on Ubuntu.

2.3 Installing dependencies

The following packages are needed to compile sasc-ng.

apt-get install linux-headers-`uname -r` build-essential subversion mercurial openssl gettext libssl-dev screen libv4l-dev


3 Installing sasc-ng

3.1 Getting sasc-ng source

cd /usr/local/src
hg clone http://85.17.209.13:6100/sc
cd /usr/local/src/sc
chmod +x contrib/sasc-ng/configure
chmod +x contrib/sasc-ng/dvbloopback/module/config_dvb.pl

3.2 Patch sasc-ng (r 620)

There is serious heap trampling occurring in sasc-ng due to a compilation mis-match. This can manifest as instability, hanging threads, and/or crashes. This may affect more than the latest version of sasc-ng (version 620 as of this writing) and the patch below will likely work for previous versions:

diff -r 29b7b5f231c8 contrib/sasc-ng/Makefile
--- a/contrib/sasc-ng/Makefile  Sat Jul 21 20:51:33 2012 +0200
+++ b/contrib/sasc-ng/Makefile  Wed Jul 03 23:34:46 2013 -0400
@@ -26,6 +26,18 @@
   DEFINES += ${AUXSERVER_OPTS}
 endif

+#------------------------------------------------------------------------
+# This needs to match what's in 
+#    ./contrib/sasc-ng/sc/PLUGINS/src/sc-src/Makefile
+# otherwise, the cCam object definitions will not be
+# consistent, leading to heap trampling and instability.
+#------------------------------------------------------------------------
+# max number of CAIDs per slot
+MAXCAID := $(shell sed -ne '/define MAXCASYSTEMIDS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' ./sc/ci.c)
+ifneq ($(strip $(MAXCAID)),)
+  DEFINES += -DVDR_MAXCAID=$(MAXCAID)
+endif
+
 CXXFLAGS += -g
 CFLAGS   += -g
 SC_FLAGS += -g

Copy/paste the patch into a local file (e.g. ~/sasc.cCam.patch) using your favourite editor.

cd /usr/local/src/sc
patch -p1 < ~/sasc.cCam.patch

3.3 Don't treat warnings as errors

There's a setting in the makefile that, should you get a warning during compile, it'll treat this as an error. It's best to just shut this off.

cd /usr/local/src/sc/contrib/sasc-ng/
nano Makefile

On the 11th line it should say

CXXFLAGS ?= -Wall -D__user= -Werror 

Remove the "-Werror", so it looks like this:

CXXFLAGS ?= -Wall -D__user= 

3.4 Configuring and compiling

Do not use --shared! It will cause segfaults. Should you do use it, you'll have to remove your sc folder and try again. (There's no "make clean" here)

To avoid some tune lock bug in sc is recommended to apply this patch [1]

cd /usr/local/src/sc/contrib/sasc-ng/
./configure
make
make module 

3.5 Installing the files

Installing the dvbloopback module (so it can load at boot)

rm /lib/modules/`uname -r`/misc/dvbloopback.ko
cd /usr/local/src/sc/contrib/sasc-ng/
cp sasc-ng /usr/bin
cp ./sc/PLUGINS/lib/* /usr/lib/
mkdir /lib/modules/`uname -r`/misc
/usr/bin/install dvbloopback.ko /lib/modules/`uname -r`/misc/
depmod

3.6 Loading the modules

since we installed the module at the appropriate position we can modprobe it:

modprobe dvbloopback

If you have multiple adapters (like I do, the reason why I'm using sasc-ng) you need to specify the amount of adapters you have. I have 3 adapters, so I do:

modprobe dvbloopback num_adapters=3


3.7 Loading at boot

I used to advise you to add a line to your /etc/modules file to load the module at boot. This is no longer necessary with the new runsasc script (which you can find below.) In fact, removing it (therefore putting the script in charge of loading the module) resolved a few headaches for me.

3.8 Starting sasc-ng

To start sasc-ng:

LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng -j 0:1 --cam-budget

To use it with MythTV:

LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng -j 0:1 --cam-budget --sid-allpid --sid-nocache
LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng  -j 0:3 -j 1:4 -j 2:5 --cam-budget --sid-nocache -d 0xf0a --cam-dir /etc/camfiles

To use sasc-ng with newcs, add:

cardclient.conf:

newcamd:localhost:15000:1/0602/ffff:dummy:dummy:0102030405060708091011121314

4 Cleaning up

4.1 Moving files & folders

We will give our camfiles (cardclient.conf) a proper home & copy sasc-ng to the binary folder.

mkdir /etc/camfiles
cd /usr/local/src/sc/contrib/sasc-ng/
mv sc_files/* /etc/camfiles/
cp sasc-ng /usr/bin/

Now we'll move the needed library files to the correct place.

cp /usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/* /usr/lib/

Now we'll edit the startup files.

nano /usr/local/bin/runsasc

And paste this script (you can ignore the DRIVERDIR variable in this script. Since we copied the module to our kernel tree we can just "modprobe dvbloopback" without any path.) Pay attention to the number of adapters you're loading! I've set it to 3 and have added the necessary "-j" options.

#!/bin/bash 

# Script to automate running of SASC-NG and Drivers 

# Driver directory 
DRIVERDIR="/usr/local/src/mythtv.cvs/sasc-ng" 
# Path to SASC-NG binary 
SASCPRG="sasc-ng" 
# Path to CAM Directory 
CAMDIR="/etc/camfiles/" 
# Number of DVB Cards you have in your system dedicated to SASC-NG 
ADAPTERS="3" 
# Startup Options passed to SASC-NG.  Adjust according to your devices. 
#OPTIONS="-r 0 -v 2 -o" 
OPTIONS="-j 0:3 -j 1:4 -j 2:5 --cam-budget --sid-allpid --sid-nocache --cam-dir" 
# Number of times runsasc will attempt to restart SASC-NG after a crash has occured (set to 0 for no limit) 
MAXTRIES=10 
# Minimum runtime required (in seconds) for SASC-NG to continue restart attempts 
MINRUN=20 

## End Configuration Section ## 

SASCCMD="$SASCPRG $OPTIONS $CAMDIR" 
KILL="/usr/bin/killall -q -TERM" 

# Detect whether the DVBLooopback driver is already loaded 
# and return 0 if it *is* loaded, 1 if not: 
function DriverLoaded() 
{ 
  grep -qse dvbloopback /proc/modules 
} 

# Load all DVBLoopback driver modules needed for your hardware: 
function LoadDriver() 
{ 
  modprobe dvbloopback num_adapters=$ADAPTERS 
  sleep 5 
} 

# Unload all DVBLoopback driver modules loaded in LoadDriver(): 
function UnloadDriver() 
{ 
  rmmod dvbloopback
} 

# Load driver if it hasn't been loaded already: 
if ! DriverLoaded; then 
   LoadDriver 
   fi 

LASTRESTART=$(date +%s) 
LOOPCOUNT=0 
while (true) do 
      if [ $LOOPCOUNT -le $MAXTRIES ] || [ $MAXTRIES -eq 0 ] ; then 
        eval "screen -D -m -S sasc-ng $SASCCMD &" 
        # Wait for SASC-NG to initialize then do rest 
        sleep 10 
        touch /tmp/SASC_COMPLETE 
      else 
        $KILL runsasc 
      fi 
      # Remember PID of SASC-NG process 
      PID=$! 
      # Wait for SASC-NG to end or signal to arrive 
      wait $PID 
      # Remember return value of SASC-NG 
      RET=$? 
      if test $RET -eq 0 -o $RET -eq 2; then exit; fi 
      TIMEOFDEATH=$(date +%s) 
      RUNTIME=$((TIMEOFDEATH - LASTRESTART)) 
      if [ $TIMEOFDEATH -le $(($LASTRESTART + $MINRUN)) ] ; then 
        echo "`date` SASC-NG crashed in $RUNTIME seconds. Minimum required runtime for SASC-NG is $MINRUN seconds. Killing runsasc process..." 
        $KILL runsasc 
      fi 
      echo "`date` Reloading DVBLoopback drivers" 
      $KILL sasc-ng 
      sleep 10 
      UnloadDriver 
      LoadDriver 
      LASTRESTART=$(date +%s) 
      LOOPCOUNT=$((LOOPCOUNT+1)) 
      echo "`date` Restarting SASC-NG $LOOPCOUNT time(s). Maximum retries set to $MAXTRIES" 
      done

And give it the proper permissions:

chmod 755 /usr/local/bin/runsasc
chmod +x /usr/local/bin/runsasc

4.2 Init script

An init script will take care of sasc-ng starting up at boot.

nano /etc/init.d/sascd

Add these lines:

#! /bin/bash 
# 
# sasc start-stop script 
# 

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
NAME="runsasc" 
DESC="SASC-NG" 
DAEMON="sasc-ng" 

ENABLED=0 
test -f /etc/default/sascc && . /etc/default/sascc 
test "$ENABLED" != "0" || exit 0 

rm -f /tmp/SASC_COMPLETE 

LOOP=0 
case "$1" in 
  start) 
         if ! ps -C sasc-ng > /dev/null 2>&1; then 
         echo -e "Starting $DESC: $NAME. \n" 
         runsasc & 
         until [ -e /tmp/SASC_COMPLETE ] || [ $LOOP -eq $TIMEOUT ] ; do 
           sleep 1 
           LOOP=$((LOOP+1)) 
         done 
         if [ $LOOP -eq $TIMEOUT ]; then 
           echo -e "SASC-NG startup sequence has timed out in $TIMEOUT seconds. SASC-NG will not start. \n" 
           exit 1 
         fi 
         echo -e "SASC-NG startup time was $LOOP second(s). \n" 
         echo -e "SASC-NG startup sequence completed. \n" 
         else 
         echo -e "SASC-NG is already running. \n" 
         fi 
         ;; 
  stop) 
         if ps -C sasc-ng > /dev/null 2>&1; then 
         echo -e "Stopping $DESC: $NAME. \n" 
         sleep 3 
         killall -q -TERM $NAME 
         killall -q -TERM $DAEMON 
         sleep 5 
         rmmod dvbloopback.ko 
         else 
         echo -e "SASC-NG is not running. \n" 
         fi 
         ;; 
  restart|force-reload) 
         if ps -C sasc-ng > /dev/null 2>&1; then 
         echo -e "Restarting $DESC: $NAME. \n" 
         sleep 3 
         killall -q -TERM $NAME 
         killall -q -TERM $DAEMON 
         sleep 5 
         rmmod dvbloopback.ko 
         sleep 2 
         runsasc & 
         until [ -e /tmp/SASC_COMPLETE ] || [ $LOOP -eq $TIMEOUT ] ; do 
           sleep 1 
           LOOP=$((LOOP+1)) 
         done 
         if [ $LOOP -eq $TIMEOUT ]; then 
           echo -e "SASC-NG startup sequence has timed out in $TIMEOUT seconds. SASC-NG will not start. \n" 
           exit 1 
         fi 
         echo -e "SASC-NG startup time was $LOOP second(s). \n" 
         echo -e "SASC-NG startup sequence completed. \n" 
         else 
         echo -e "SASC-NG is not running. \n" 
         fi 
         ;; 
  *) 
         N=/etc/init.d/$NAME 
         echo "Use: $N {start|stop|restart|force-reload}" >&2 
         exit 1 
        ;; 
esac 

rm -f /tmp/SASC_COMPLETE 

exit 0

And now we set the proper permissions and actually add it to the runlevels:

chmod +x /etc/init.d/sascd
update-rc.d sascd defaults 35 20

We just need one more config file:

nano /etc/default/sascc

Add this:

# /etc/default/sascc 
# Default SASC-NG startup config 

# Change to 1 to enable sasc-ng's init-script 
ENABLED=1 

# DVBLoopback Device creation timeout (in seconds) 
TIMEOUT=60

5 Additional files

We're planning on using this thing legally, with NewCS in our own system. We need a cardclient.conf file for that:

nano /etc/camfiles/cardclient.conf

And put this in it. (I added some more lines so you'll get an idea as to how this thing works.)

#
# Comment lines can start with # or ;
#
# every client line starts with the client name, followed by some arguments:
# 'hostname' is the name of the server
# 'port'     is the port on the server
# 'emm'      is a flag to allow EMM transfers to the server
#            (0=disabled 1=enabled)
# 'caid'     (optional) caid on which this client should work
# 'mask'     (optional) mask for caid e.g. caid=1700 mask=FF00 would allow
#            anything between 1700 & 17FF.
#            Default is 1700 & FF00. If only caid is given mask is FFFF.
#            You may give multiple caid/mask values comma separated
#            (e.g. 1702,1722,0d0c/ff00).
# 'username' is the login username
# 'password' is the login password
#
# radegast client
#radegast:hostname:port:emm/caid/mask
#
# aroureos client
# 'hexbase'
# 'hexserial' card data for which EMM updates should be send
#aroureos:hostname:port:emm/caid/mask:hexbase:hexserial
#
# camd33 client (tcp protocol)
# 'aeskey'   is the AES key (32bytes), disable encryption if missing
#camd33:hostname:port:emm/caid/mask:username:password:aeskey
#
# camd35 client (udp protocol)
#camd35:hostname:port:emm/caid/mask:username:password
#
# cardd client
#cardd:hostname:port:emm/caid/mask:username:password
#
# buffy client
# 'aeskey'   is the AES key (32bytes), disable encryption if missing
#buffy:hostname:port:emm:username:password:aeskey
#some examples
#newcamd:192.168.0.10:10000:1/1801/FF00:mythtv:xxxxxxxx:XXXXXXXXXXXXXXXXXXXXXXXXXXXX
#radegast:192.168.0.10:10001:1/1801/FF00 
#
# newcamd client
# 'cfgkey' is the config key (28bytes)
#newcamd:hostname:port:emm/caid/mask:username:password:cfgKey
newcamd:127.0.0.1:10000:1/1801/FF00:test:test:0102030405060708091011121314
#
# gbox client
#
# NOTE: hostname & port will be ignore. GBOX must be runnning on the local
# machine. For convinience you should choose localhost:8004
#gbox:hostname:port:emm/caid/mask
#newcamd:hostname:port:emm/caid/mask:username:password:cfgKey 
#newcamd:localhost:15000:1/0602/ffff:dummy:dummy:0102030405060708091011121314
radegast:192.168.1.2:10001:0/0100/ffff

6 Other Tutorials

  • Install Gimp: Install and compile the latest GIMP from trunk (which has the single-window mode)


<shtml keyname="primary key" hash="c1b8cfb8a167caa35a5ec82da8e27068">

<script type="text/javascript" src="http://serve.adimp.net/serve.js"></script> <script type="text/javascript"> adimp.id = 2; adimp.type = 1; adimp.generate(); </script></shtml>

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox