#!/bin/bash
# Added key-download for OScam-emu Patch
# starts config.sh if patched
# allow save Config if nit patched
### CONFIG - START
# Enable colored output-lines on shell? [yes/no]
ENABLECOLORS="yes"
# TRUNKs
svnURL="http://178.17.169.213/svn/oscam/trunk"
# TAGs
svnURLtags="http://178.17.169.213/svn/oscam/tags"
svnTAGSver="1.10"
# MODERNs
svnURLmodern="http://178.17.169.213/svn/oscam-addons/modern"
#Keys
SCURL="http://www.uydu.ws/deneme6.php?file=SoftCam.Key"
#patch-name
patchNAME="oscam-emu.patch"
#Config-name
ConfigName="/tmp/compile/config.h"
### CONFIG - END
. /var/emu/script/functions.sh
[ -z $IPURL ] && clear && echo -e "\033[1;31mVariablen Konfigurationsfehler!\033[0m" && exit 1
[ -z $OSBIN ] && clear && echo -e "\033[1;31mVariablen Konfigurationsfehler!\033[0m" && exit 1
[ -z $CAMBINS ] && clear && echo -e "\033[1;31mVariablen Konfigurationsfehler!\033[0m" && exit 1
ScriptVer="1.3.0"
#pruefe System ob ARM (
Raspberry)
[[ "$(uname -m)" = "arm"* ]] && ARM=$(uname -m) || ARM=""
if [ "$ENABLECOLORS" = "yes" ]; then
ROT=`tput setaf 1`
GRUEN=`tput setaf 2`
BOLD=`tput bold`
NORM='tput op && tput sgr0'
else
ROT="" ; GRUEN="" ; BOLD="" ; NORM=""
fi
if [ `uname -m` = 'x86_64' ]; then
SYSBIT="64"
SYSBIT="64"
OSCAMbin="oscam.x86_64"
else
SYSBIT="32"
OSCAMbin="oscam.x86"
fi
CPUcores=$(grep ^processor /proc/cpuinfo | wc -l)
[ -z "$CPUcores" ] && CPUcores=1
[[ "$CPUcores" < "1" ]] && CPUcores=1
#Linux Version? (Debian/Ubuntu)
if [ -f /usr/bin/lsb_release ]; then
_LINUX=$(lsb_release -d|cut -d":" -f2|awk {'print $1'})
if [ "$_LINUX" = "Debian" ]; then
LINUXVERSION=$(lsb_release -d|cut -d":" -f2|awk {'print $3'})
elif [ "$_LINUX" = "Ubuntu" ]; then
LINUXVERSION=$(lsb_release -d|cut -d":" -f2|awk {'print $2'})
fi
fi
if [ -z "$LINUXVERSION" ]; then
[ -f /etc/debian_version ] && LINUXVERSION=$(cat /etc/debian_version|cut -c1)
fi
#### functions
function collect_needed_packs () {
InstallPAK=""
NEEDPACK=${needpacks
[*]}
for PACK in $NEEDPACK; do
if [ -z "$(dpkg -l | grep "ii" | awk {'print $2'} | grep -xi $PACK)" ];then
[ -z "$InstallPAK" ] && InstallPAK="$PACK" || InstallPAK+=" $PACK"
fi
done
}
install_packs() {
echo " "
echo "Installiere benoetigte Pakete zum Kompilieren von OScam.."
echo " "
sleep 2
collect_needed_packs
apt-get clean
apt-get update -f
#echo -e "\n... $InstallPAK ...\n"
apt-get install -y $InstallPAK
# libusb-1.0-0-dev
InstallLIBUSB=0
if [ -n "$LINUXVERSION" ]; then
if [ "$_LINUX" = "Debian" ]; then
if [ "$(echo $LINUXVERSION|cut -c1)" -gt "7" ]; then
InstallLIBUSB=1
elif [ "$(echo $LINUXVERSION|cut -c1)" = "7" ]; then
InstallLIBUSB=1
elif [ "$(echo $LINUXVERSION|cut -c1)" = "6" ]; then
InstallLIBUSB=1
fi
elif [ "$_LINUX" = "Ubuntu" ]; then
InstallLIBUSB=1
fi
else
InstallLIBUSB=1
fi
[ "$InstallLIBUSB" == "1" ] && apt-get install -y $NP
echo " "; sleep 1
apt-get clean
if [ "`find / -name libusb.h`" = "" ]; then
install_libusb "1.0.9"
fi
touch $CheckInstalledFile >/dev/null 2>&1
echo " "
}
install_libusb() {
if [ -z "$1" ]; then
LibVer="1.0.8"
else
LibVer=$1
fi
cp -f /var/emu/libs/libusb-${LibVer}.tar.bz2 /tmp/ >/dev/null 2>&1
if [ ! -f "/tmp/libusb-${LibVer}.tar.bz2" ]; then
echo -n "Lade libusb-${LibVer}.."
wget -o $WGETLOG $IPURL/scripts/lib/libusb-${LibVer}.tar.bz2 -P /tmp/ >> /dev/null 2>&1
if [ ! "`grep '200 OK' $WGETLOG`" = "" ] ; then
echo " done"
rm -f $WGETLOG
else
echo -e "\033[1;31mVerbindungsfehler! Abbruch!\033[0m"
rm -f $WGETLOG
exit 1
fi
fi
echo -n "Installiere libusb-${LibVer}.."
cd /tmp
if [ -d "libusb-${LibVer}" ]; then
rm -rf libusb-${LibVer}
fi
tar xjf libusb-${LibVer}.tar.bz2 >> /dev/null 2>&1
echo -n ".entpackt."
cd /tmp/libusb-${LibVer} >> /dev/null 2>&1
echo -n ".configure."
./configure >> /dev/null 2>&1
echo -n ".make."
make -j$CPUcores >> /dev/null 2>&1
echo -n ".make install."
make install >> /dev/null 2>&1
if [ $? -ne "0" ]; then
echo " "
echo -e " \033[1;31mInstallation fehlgeschlagen!\033[0m"
echo "Bitte versuchen Sie den manuellen Weg um heraus zu finden was hierbei schief geht:"
echo " cd /tmp/libusb-${LibVer}"
echo " ./configure"
echo " make"
echo " make install"
echo "-------------------------------------------------------------------------------"
exit 1
else
echo " done"
rm -rf /tmp/libusb-${LibVer}* >> /dev/null 2>&1
ln -fs /usr/local/lib/libusb-1.0.so.0 /lib/libusb-1.0.so.0
fi
}
CheckInstalledPacks() {
[ ! -f "$CheckInstalledFile" ] && install_packs
[ ! -f "/lib/libusb-1.0.so.0" ] && ln -fs /usr/local/lib/libusb-1.0.so.0 /lib/libusb-1.0.so.0 >/dev/null 2&>1
}
renewbinary() {
rm -rf $OSBIN
mv -f $filedir_tmp/$oscamBUILD/build_dir/oscam $OSBIN
echo " "
echo "Die neue $OSVERSION befindet sich in $CAMBINS/oscam/"
echo " "
}
OScamRestart() {
if [ "$AutoCompileIT" = "0" ]; then
echo "-------------------------------------------------------------------------------"
echo ""
echo "Soll OScam jetzt neu gestartet werden?"
echo -en "\033[1;33m[J]a | []Nein \033[0m"
read key
case $key in
[JjYy]|[jJ][aA]|[yY][eE][sS])
echo " "
oscam restart
;;
*)
sleep 0.5
;;
esac
echo " "
echo "-------------------------------------------------------------------------------"
echo " "
else
oscam restart
fi
}
loadConfig() {
if [ ! -f "$filedir_tmp/$patchNAME" ]; then
echo "-------------------------------------------------------------------------------"
echo ""
echo "Moechten Sie die gespeicherte Config verwenden?"
echo -en "\033[1;33m[J]a | []Nein \033[0m"
read key
case $key in
[JjYy]|[jJ][aA]|[yY][eE][sS])
echo " "
cp $ConfigName $filedir_tmp/$oscamBUILD
USeConfigs=1
;;
*)
USeConfigs=0
sleep 0.5
;;
esac
echo " "
echo "-------------------------------------------------------------------------------"
echo " "
fi
}
saveConfig() {
if [ ! -f "$filedir_tmp/$patchNAME" ]; then
echo "-------------------------------------------------------------------------------"
echo ""
echo "Moechten Sie die Config fuer spaetere Kompilier-Vorgaenge speichern?"
echo -en "\033[1;33m[J]a | []Nein \033[0m"
read key
case $key in
[JjYy]|[jJ][aA]|[yY][eE][sS])
echo " "
cp $filedir_tmp/$oscamBUILD/config.h $filedir_tmp
#SaveConfigs=1
;;
*)
#SaveConfigs=0
sleep 0.5
;;
esac
echo " "
echo "-------------------------------------------------------------------------------"
echo " "
fi
}
WhichRevision() {
echo "-------------------------------------------------------------------------------"
echo ""
echo "Moechten Sie eine bestimmte svn Revisionsnummer kompilieren oder die aktuelle?"
echo -en "\033[1;33m[04801] | []Aktuelle \033[0m"
read key
case $key in
[0-9][0-9][0-9][0-9][0-9])
echo " "
revision_num=$key
;;
"")
revision_num=""
;;
*)
echo -e " \033[1;31mUngueltige Eingabe!\033[0m"
sleep 1 ; WhichRevision
;;
esac
echo " "
echo "-------------------------------------------------------------------------------"
echo " "
}
Keyrenewal() {
echo "-------------------------------------------------------------------------------"
echo ""
echo "Sollen die Keys aus /var/etc/ verwendet werden, oder sollen sie aktualisiert werden?"
echo -en "\033[1;33m[A]ktualisieren | []Vorhandene Keys \033[0m"
read key
case $key in
[aA])
echo " "
cd /var/keys/ ; wget -O SoftCam.Key $SCURL
ln -fs /var/keys/SoftCam.Key $filedir_tmp/$oscamBUILD/SoftCam.Key
cd ${filedir_tmp}/${oscamBUILD}
;;
*)
ln -fs /var/keys/SoftCam.Key $filedir_tmp/$oscamBUILD/SoftCam.Key
sleep 1
;;
esac
echo " "
echo "-------------------------------------------------------------------------------"
echo " "
}
#### vars
CheckInstalledFile="/var/emu/conf/.oscam_compile_check.OK"
NP_old="build-essential cmake gcc subversion libusb-dev libssl-dev tar bzip2 gzip wget gettext"
NP1="build-essential autoconf automake cmake make patch gcc g++ pkg-config subversion"
NP2="libccid libtool libglib2.0-dev libssl-dev libpcsclite1 libpcsclite-dev"
NP3="gettext tar bzip2 gzip ncurses-bin flex bison wget libpng3 zlib1g-dev sudo"
NP="libusb-1.0-0-dev"
needpacks=("$NP1" "$NP2" "$NP3")
oscamBUILD="oscam-svn"
WGETLOG="/tmp/.wget.log"
filedir_tmp_tool="/tmp/compile/toolchains"
filedir_tmp="/tmp/compile"
ScriptName=$(basename $0)
svnABLE="trunk"
AutoCompileIT=0
USeConfigs=0
SaveConfigs=0
#### main
$NORM
echo "$ScriptName v$ScriptVer"
case "$1" in
[hH][eE][lL][pP]|[hH][iI][lL][fF][eE]|\?)
echo "Usage: $0"
echo "or: $0 <revision>"
echo "or: $0 -auto"
echo "or: $0 -tags"
echo "or: $0 -tags -auto"
echo "or: $0 -modern"
echo "or: $0 -modern -auto"
exit 0
;;
-tag*|--tag*)
svnABLE="tags"
oscamBUILD="oscam-tags"
;;
-mod*|--mod*)
svnABLE="modern"
oscamBUILD="oscam-modern"
;;
-auto|--auto)
AutoCompileIT=1
;;
esac
case "$2" in
-auto|--auto)
AutoCompileIT=1
;;
esac
[ ! -d "$filedir_tmp" ] && mkdir -p $filedir_tmp && chmod 777 $filedir_tmp >/dev/null 2>&1
cd $filedir_tmp
CheckInstalledPacks
[ "$AutoCompileIT" = "0" ] && WhichRevision || revision_num=""
if [ -z "$revision_num" ]; then
if [ "$svnABLE" = "tags" ]; then
revision_num=$(svn info $svnURLtags/$svnTAGSver | grep '^Revision:' | sed -e 's/^Revision: //')
echo "Lade aktuelle $oscamBUILD $svnTAGSver Revision ${revision_num}..."
svn co $svnURLtags/$svnTAGSver ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
elif [ "$svnABLE" = "modern" ]; then
revision_num=$(svn info $svnURLmodern | grep '^Revision:' | sed -e 's/^Revision: //')
echo "Lade aktuelle $oscamBUILD Revision ${revision_num}..."
svn co $svnURLmodern ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
else
revision_num=$(svn info $svnURL | grep '^Revision:' | sed -e 's/^Revision: //')
echo "Lade aktuelle $oscamBUILD Revision ${revision_num}..."
svn co $svnURL ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
fi
else
if [ "$svnABLE" = "tags" ]; then
echo "Lade $oscamBUILD $svnTAGSver Revision ${revision_num}..."
svn co -r $revision_num $svnURLtags/$svnTAGSver ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
elif [ "$svnABLE" = "modern" ]; then
echo "Lade aktuelle $oscamBUILD Revision ${revision_num}..."
svn co -r $revision_num $svnURLmodern ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
else
echo "Lade $oscamBUILD Revision ${revision_num}..."
svn co -r $revision_num $svnURL ${filedir_tmp}/${oscamBUILD}
if [ $? -ne "0" ]; then
echo -e " \033[1;31mVerbindungsfehler! Abbruch\033[0m"
exit 1
fi
fi
fi
if [ $? -ne "0" ]; then
echo " "
echo -e " \033[1;31mVerbindungsfehler! Abbruch!\033[0m"
exit 1
fi
echo " "
if [ -f $ConfigName ]; then
loadConfig
fi
if [ ! -d "${filedir_tmp}/${oscamBUILD}" ]; then
echo $ROT "ERROR: ${filedir_tmp}/${oscamBUILD} existiert nicht. Download fehlgeschlagen? Abbruch!" ; $NORM
exit 1
else
if [ "$AutoCompileIT" = "0" ]; then
if [ "$USeConfigs" = "0" ]; then
cd ${filedir_tmp}/${oscamBUILD}
if [ ! -f "$filedir_tmp/$patchNAME" ]; then
echo " "
echo "Im folgenden Menue koennen Sie einstellen was OScam unterstuetzen soll "
echo "Mit der <Leer-taste> waehlen sie was aus.."
echo "Mit der <Enter-taste> bestaetigen sie.."
echo "Mit der <ESC-taste> kehren sie ein Menue zurueck.."
echo " "
read -p "Druecken Sie bitte <Enter> um fortzufahren..."
./config.sh -g
saveConfig
fi
else
echo "Config gefunden"
fi
fi
fi
if [ -f "$filedir_tmp/$patchNAME" ]; then
if [ "$patchNAME" = "oscam-emu.patch" ]; then
patch -p0 < $filedir_tmp/$patchNAME && echo "$patchNAME gefunden und gepatched" && echo " " && read -p "Druecken Sie bitte <Enter> um fortzufahren..."
else
patch -p0 < $filedir_tmp/$patchNAME && echo "$patchNAME gefunden und gepatched" && read -p "Druecken Sie bitte <Enter> um fortzufahren..."
fi
Keyrenewal
echo " "
echo "Im folgenden Menue koennen Sie einstellen was OScam unterstuetzen soll "
echo "Mit der <Leer-taste> waehlen sie was aus.."
echo "Mit der <Enter-taste> bestaetigen sie.."
echo "Mit der <ESC-taste> kehren sie ein Menue zurueck.."
echo " "
read -p "Druecken Sie bitte <Enter> um fortzufahren..."
./config.sh -g
saveConfig
fi
echo " "
if [ ! -z "$ARM" ]; then
echo "Bereite ARM Kompilierung vor..."
echo ""
else
echo "Bereite ${SYSBIT}bit Kompilierung vor..."
echo " "
fi
sleep 3
#read -p "Druecken Sie bitte <Enter> um fortzufahren..."
cd $filedir_tmp/$oscamBUILD
mkdir -p build_dir ; cd build_dir ; make clean >/dev/null 2>&1
cmake -DCS_CONFDIR=/var/etc/ ..
echo " "
echo "Folgendes Kompilieren kann einige Zeit in Anspruch nehmen... "
echo " "
[ "$AutoCompileIT" = "0" ] && read -p "Druecken Sie bitte <Enter> um fortzufahren..."
make -j$CPUcores
if [ ! -f "$filedir_tmp/$oscamBUILD/build_dir/oscam" ]; then
echo $ROT "ERROR: compile fehlgeschlagen? Abbruch!" ; $NORM
exit 1
else
echo " "
renewbinary
sleep 1
echo " "
# beep
echo -en "\007"
echo $GRUEN "Neue ${oscamBUILD} build $revision_num erfolgreich erstellt!" ; $NORM
fi
cd /
## cleanup
[ "$AutoCompileIT" = "0" ] && rm -rf ${filedir_tmp}/${oscamBUILD}
rm -f /tmp/config.mak.*
rm -f /tmp/oscam-config.h.bak
echo " "
OScamRestart
echo $GRUEN "Fertig! ;-)" ; $NORM
echo " "
exit 0