• Hola Invitado, nos gustaría recordarte que mantener este sitio en línea conlleva unos gastos mensuales y anuales.

    Sin vuestra ayuda mensual no es posible seguir en pie, no hay mucho más que contar.

    Si quieres colaborar para que sea posible por lo menos seguir en pie como comunidad, puedes hacerlo mediante alguno de los métodos disponibles en esta página: https://www.lonasdigital.com/donaciones/

    Recuerda que si necesitas invitación para acceder al foro, puedes solicitarla en nuestro Grupo de Telegram


proyecto script oscam

††LUCIFER††

Intencion del proyecto:


Ir modificando el script entre todos, ya sea aportando codigo, o aportando ideas para ir poniendolas en el script..., no hace falta que tengais idea ni conocimientos, simplemente ya sirve que aporteis una idea que se os ocurra que os gustaria que hiciera el script, y ya entre todos se vera como hacerlo...


script base:


A continuacion os dejo el script que he realizado, funcional, sobre el que añadir mas cosas que se os ocurran, que es la intencion del proyecto:


El script hace en estos momentos:


- Chequea el proceso oscam y si no lo encuentra arranca oscam
- Chequea si hay conexion a internet, si hay no hace nada, si se pierde no hace nada, y cuando vuelve internet para oscam, y lo vuelve a reiniciar.
- Chequea si hay errores en el log que generamos con oscam, busca los errores:
ins40
trylock
not found
timeout


y si los encuentra reinicia oscam...


En todos los casos de reinicio de oscam se crea log sobre los mismos...


log de funcionamiento:






dhcppc0:/usr/script# sh oscamcheck.sh





Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
grep: found: No such file or directory
Oscam esta funcionando
Si hay Internet
2012/08/13 20:14:06 5DCAC8 p cccam: ecm trylock: got lock---> encuentra error trylock se reinicia oscam


y se crea log con los reinicios y errores:




Se han encontrado errores ins40 o trylock : Mon Aug 13 19:30:44 CEST 2012
Oscam no se encuentra reinciando : Mon Aug 13 20:20:15 CEST 2012
Oscam no se encuentra reinciando : Mon Aug 13 20:26:31 CEST 2012

y SCRIPT PARA UTILIZAR ACTUALIZADO A FECHA 16-08-2012






Código:
###########SCRIPT OSCAM PROYECTO LIBRE########
#!/bin/sh


#PARAMETROS DE CONFIGURACION
emuoscam=/var/emu/oscam # Ubicacion del binario oscam y archivos configuracion arrancado en modo debugall
oscamconf=/var/etc/oscam # Ubicacion de los archivos de configuracion de oscam
oscamL=/media/hdd/logoscam.log # Ubicacion donde oscam crea un archivo log para ver el debug, configurable en oscam.conf
oscamC=/var/log/oscamcheck.log # Archivo que se crea sobre procesos del script oscam.
NumT="10" # numero errores a buscar
fecha=`date` # Formato de fecha
dns=/usr/bin/noip2 # Ubicacion programa noip2
testeo=10 # Tiempo en segundos que el script hace comprobaciones


#BUSCAR PROCESO OSCAM SI NO LO ENCUENTRA SE REINICIA
while [ true ];
do
if pgrep oscam >/dev/null
then
echo "Oscam esta funcionando"
else
echo "Oscam no se encuentra reinciando : $fecha" >> $oscamC
$emuoscam -c $oscamconf


fi
#REINICIO OSCAM EN CASO PERDIDA INTERNET CUANDO VUELVE
CUENTA=$(ping -c 1 www.google.es | grep received | awk -F ',' '{print $2}' | awk -F ' ' '{print $1}')
    if [ $CUENTA = 1 ];then    
 echo "Si hay Internet"
    else
 echo "No hay internet, esperamos que vuelva"
 INTERNET="NO"
 while [ $INTERNET = NO ];
 do
 CUENTA=$(ping -c 1 www.google.es | grep received | awk -F ',' '{print $2}' | awk -F ' ' '{print $1}')
 if [ $CUENTA = 1 ];then
 echo "Ya hay Internet, reiniciamos oscam y actualizamos noip2 : $fecha" >> $oscamC
 INTERNET="SI"
 killall -9 noip2
 sleep 2 
 $dns
 sleep 2
 killall -9 oscam
 sleep 1
 $emuoscam -c $oscamconf
 else
 echo "No hay internet todavia"
 fi
 done
    fi
#REINICIO OSCAM EN CASO DE ERRORES INS4O Y TRYLOCK
if ((tail -n 50 $oscamL | grep ins40) || (tail -n 10 $oscamL | grep trylock))
then
echo "Se han encontrado errores ins40 o trylock : $fecha" >> $oscamC
cp $oscamL /media/hdd/pvr
sleep 5
rm $oscamL
sleep 5
killall -9 oscam
sleep 1
$emuoscam -c $oscamconf
exit
fi
#REINICIO OSCAM EN CASO DE ERRORES TIMEOUT Y NOT FOUND
if [ "`tail -n 100 $oscamL | grep -c timeout || tail -n 100 $oscamL | grep -c not found`" -gt "$NumT" ]
then
echo "Se han encontrado errores timeout o not found : $fecha" >> $oscamC
cp $oscamL /media/hdd/pvr
sleep 5
rm $oscamL
sleep 5
killall -9 oscam
sleep 1
$emuoscam -c $oscamconf
fi
#AVISO CIERRE CONEXION
tail -n 5 $oscamL | grep tcp_conn_close >> $oscamC
sleep $testeo
 done
fi


exit 0




ACTUALIZACION PARA QUIEN UTILICE PROGRAMA NOIP2 EN SU DECO:


Código:
###########SCRIPT OSCAM  PROYECTO LIBRE########
#!/bin/sh


#PARAMETROS DE CONFIGURACION
emuoscam=/var/emu/oscam # Ubicacion del binario oscam y archivos configuracion arrancado en modo debugall
oscamconf=/var/etc/oscam # Ubicacion de los archivos de configuracion de oscam
oscamL=/media/hdd/logoscam.log # Ubicacion donde oscam crea un archivo log para ver el debug, configurable en oscam.conf
oscamC=/var/log/oscamcheck.log # Archivo que se crea sobre procesos del script oscam.
fecha=`date` # Formato de fecha
dns=/usr/bin/noip2 # Ubicacion programa noip2
testeo=10 # Tiempo en segundos que el script hace comprobaciones
#BUSCAR PROCESO OSCAM SI NO LO ENCUENTRA SE REINICIA
while [ true ];
do
if pgrep oscam >/dev/null
then
echo "Oscam esta funcionando"
else
echo "Oscam no se encuentra reinciando : $fecha" >> $oscamC
$emuoscam -d255 -c $oscamconf


fi
#REINICIO OSCAM EN CASO PERDIDA INTERNET CUANDO VUELVE
CUENTA=$(ping -c 1 www.google.es | grep received | awk -F ',' '{print $2}' | awk -F ' ' '{print $1}')
if [ $CUENTA = 1 ];then 
echo "Si hay Internet"
else
echo "No hay internet, esperamos que vuelva"
INTERNET="NO"
while [ $INTERNET = NO ];
do
CUENTA=$(ping -c 1 www.google.es | grep received | awk -F ',' '{print $2}' | awk -F ' ' '{print $1}')
if [ $CUENTA = 1 ];then
echo "Ya hay Internet, reiniciamos oscam y actualizamos noip2 : $fecha" >> $oscamC
INTERNET="SI"
killall -9 noip2
sleep 2 
$dns
sleep 2
killall -9 oscam
sleep 1
$emuoscam -d255 -c $oscamconf
else
echo "No hay internet todavia"
fi
done
fi
#REINICIO OSCAM EN CASO DE ERRORES INS4O Y TRYLOCK
if ((tail -n 50 $oscamL | grep ins40) || (tail -n 10 $oscamL | grep trylock))
then
echo "Se han encontrado errores ins40 o trylock : $fecha" >> $oscamC
killall -9 oscam
$emuoscam -d255 -c $oscamconf
fi
#REINICIO OSCAM EN CASO DE ERRORES TIMEOUT Y NOT FOUND
if ((tail -n 50 $oscamL | grep timeout) || (tail -n 10 $oscamL | grep not found))
then
echo "Se han encontrado errores ins40 o trylock : $fecha" >> $oscamC
killall -9 oscam
$emuoscam -d255 -c $oscamconf
fi
#AVISO CIERRE CONEXION
tail -n 5 $oscamL | grep tcp_conn_close >> $oscamC
sleep $testeo
done
fi


exit 0
Saludos e ir poniendo en este hilo, ideas o aportaciones para añadir o mejorar....o cuando le deis uso pues errores que os surjan...
 
Este script sirve para los que usamos una pc con oscam?

Lo uso en un ubuntu server 10.4
 
Me gusta el proyecto, a ver cuando termine exámenes si me pongo con ello.
 
Atrás
Arriba