Wednesday, June 22, 2011

Oscam auto update script for ubuntu

Oscam auto update script for ubuntu

Hi all,

I have prepeared a script that automatically checks and updates oscam to the latest version and I want to share it with you...
(I use this on Ubuntu Server 10.10)

1) create a file named: oscam_update.sh (or watever you want)

PHP Code:
sudo nano /var/local/bin/oscam_update.sh 
2) insert the following content
PHP Code:
######   ####   #####   #####    ###  ###
 ##  ##  ##     ##      ##   ##  ##  ##  ##
 ##  ##  #####  ##      #######  ##  ##  ##
 ##  ##     ##  ##      ##   ##  ##      ##
 ######  ####    #####  ##   ##  ##      ## R

####################################################################
# 18 Jan 2011
# By: billyk
# Description: Automaticaly check and update to latest oscam version
#              Also restars it after update
####################################################################
# - You can modify it to fit your needs :)
# - Add # infront of any line that you don't want to execute
####################################################################
echo "--> 1rst go to oscam's dir" cd /usr/local/bin echo " [ OK ] " echo "--> Backup previus version" #you must create a folder named: oscam_backups under /usr/local/bin sudo mv ./oscam ./oscam_backups/oscam_$(date +%m-%d-%Y-%H:%M)
echo 
" [ OK ] " echo "--> Let's remove old folder..." sudo rm -rf oscam-svn echo " [ OK ] " echo "--> Checking for latest version and create oscam-svn dir..." sudo svn co http://oscam.ump2002.net/svn/oscam/trunk oscam-svn echo " [ OK ] " echo "--> Change dir to: oscam-svn" cd oscam-svn/
echo 
" [ OK ] " echo "--> Create new folder: build_dir" sudo mkdir build_dir echo " [ OK ] " echo "Change dir to: build_dir" cd build_dir echo " [ OK ] " echo "--> Compile new version with Smargo smartreader support" sudo cmake -DHAVE_LIBUSB=/usr/local/bin/oscam-svn
# You must have the needed libs to run smartreader with oscam.
# If you do not want smartreader support...
# ...simply remove [-DHAVE_LIBUSB=1]
# so you will have this line:
# sudo cmake /usr/local/bin/oscam-svn
echo " [ OK ] " echo "--> Now... make!" sudo make echo " [ OK ] " echo "--> Finally we install the latest fersion..." sudo make install echo " [ OK ] " echo "---> ...so it's time to clean..." sudo make clean echo "OK. Now you have the latest oscam version!"
#########################################################################
# Also you can stop and start oscam from  this script
# The only thing you have to do is to remove the # from following lines...
##########################################################################
if ps x |grep -v grep |grep -c oscam >/dev/null
then
echo "Oscam is running so we will stop it & restart it" sudo killall -9 oscam echo "Oscam killed" sleep 1 echo "...so going to start it" sudo /usr/local/bin/oscam -&
echo 
"Done. Oscam is running!" echo "If oscam's settings are OK, you will have picture at 5 to 10 seconds!" echo "Chears! :)" else
echo 
"Starting oscam..." sudo /usr/local/bin/oscam -& fi ##########################################################################  

3) chmod oscam_update.sh to 755


PHP Code:
sudo chmod 755 oscam_update.sh 
4) run it!!!

PHP Code:
sudo ./oscam_update.sh 
Also you can add it as cron job and run it in a specific time of the day.
example:

PHP Code:
sudo nano /etc/crontab 
add this line (this runs at 04:00 every day)
PHP Code:
# m h dom mon dow user  command 01 04 * * * root /var/local/bin/oscam_update.sh 
Thanks to billyk for this script..

1 comment:

  1. how to conax cas7 auto update config in oscam

    ReplyDelete