G
#!/bin/bash
# Startscript fuer oscam
#
# Usage: start|stop|restart|status
#
# Erklaerung:
# Variable "port" kann mehrere Ports enthalten, z.B. port="1234 7895 3456" wenn mehrere cams activ sind
# Variable oscambin auf die Startdatei anpassen, z.B. oscambin="oscam-svn4559-arm-coolstream"
# Variable oscampath auf das Verzeichnis anpasssen, wo alle OSCam Daten liegen, z.B. oscampath="/mnt/HDA_ROOT/emu"
# Lib libnxp.so muss sich im etc Verzeichnis von OSCam befinden, wird beim start automatisch eingebunden
#
# Ein monitor per cron, ob der Dienst noch geht, kann so aussehen:
#
# crontab -e
# 0,15,30,45 * * * * /mnt/HDA_ROOT/emu/oscam.sh status | grep 'Listener';if [ "$?" -ne "0" ];then /mnt/HDA_ROOT/emu/oscam.sh restart;date >> /mnt/HDA_ROOT/emu/log/mon.log;fi
#
#
# Variable Debuglevel definieren:
# 0 = no debugging (default)
# 1 = detailed error messages
# 2 = ATR parsing info, ECM, EMM and CW dumps
# 4 = traffic from/to the reader
# 8 = traffic from/to the clients
# 16 = traffic to the reader-device on IFD layer
# 32 = traffic to the reader-device on I/O layer
# 64 = EMM logging
# 255 = debug all
oscampath="/mnt/HDA_ROOT/emu"
oscambin="oscam-svn4559-arm-coolstream"
port="12345"
monlog="/$oscampath/mon.log"
debuglevel="d0"
libfile="$oscampath/etc/libnxp.so"
monlog="/$oscampath/mon.log"
echo 2 > /proc/cpu/alignment
_pruefe()
{
if [ "$?" -ne "0" ]
then
echo -e "RC: 1, abbruch"
exit 1
fi
}
_start()
{
ldsoconf=$(cat /etc/ld.so.conf | grep -v '#' | head -n 1)
cp $libfile $ldsoconf
_pruefe
/sbin/ldconfig
_pruefe
$oscampath/$oscambin -$debuglevel -c /mnt/HDA_ROOT/emu/etc &
_pruefe
}
_stop()
{
ps aux | grep '$oscampath/$oscambin' | grep -v 'grep' 2>&1 > /dev/null
if [ "$?" == "0" ]
then
killall -15 $oscambin 2>&1 > /dev/null
sleep 1
fi
while (ps aux | grep '$oscampath/$oscambin' | grep -v 'grep' 2>&1 > /dev/null)
do
killall -9 $oscambin 2> /dev/null 1> /dev/null
sleep 2
_pruefe
done
}
_status()
{
rc=0
ps aux | grep '$oscampath/$oscambin' | grep -v 'grep' 2>&1 > /dev/null
if [ "$?" -ne "0" ]
then
echo "`date +[%y-%m-%d__%H:%M:%S]` - Dienst inaktiv" | tee -a $monlog
exit 1
else
echo -e "`date +[%y-%m-%d__%H:%M:%S]` - Dienst aktiv"
netstat -a 1> $oscampath/netstat.tmp 2> /dev/null
for p in $port
do
grep 'LISTEN' $oscampath/netstat.tmp | grep '$p' 2>&1 > /dev/null
if [ "$?" -ne "0" ]
then
echo -e "`date +[%y-%m-%d__%H:%M:%S]` - Listener $p ist zu!" | tee -a $monlog
rc=1
else
echo -e "`date +[%y-%m-%d__%H:%M:%S]` - Listener $p offen" | tee -a $monlog
rc=0
fi
done
rm $oscampath/netstat.tmp
fi
if [ "$rc" -ne "0" ]
then
exit 1
fi
}
case "$1" in
start)
_status | grep 'Dienst inaktiv' 2>&1 > /dev/null
if [ "$?" -eq "0" ]
then
_start
sleep 1
_status
else
echo "Dienst bereits gestartet"
exit 0
fi
;;
stop)
_stop
_status
;;
restart)
_stop
_status | grep 'Dienst inaktiv' 2>&1 > /dev/null
if [ "$?" -eq "0" ]
then
_start
_status
else
exit 1
fi
;;
status)
_status
;;
*)
echo "Usage: start|stop|restart|status"
exit 1
;;
esac
Wir verwenden Cookies und ähnliche Technologien für folgende Zwecke:
Akzeptieren Sie Cookies und diese Technologien?
Wir verwenden Cookies und ähnliche Technologien für folgende Zwecke:
Akzeptieren Sie Cookies und diese Technologien?