#!/bin/sh
#
# Â
Copyright 1996-2015, zoelechat@SamyGO
# modded by TDCroPower @ 25.06.2016
#
# Environment Variables
. /dtv/SGO.env
#
# Configuration
#
OSCAMDIR=$SYSROOT/opt/privateer/usr/bin/oscam/ # OScam directory
SODIR=$SYSROOT/opt/privateer/usr/libso/ # so directory
#BUILD=oscam-svn10666-samsungtv-webif # OScam build filename
BUILD=oscam-svn11576-samsungtv-webif-dvbapi-upx
#BUILD=oscam-svn11388-samsungtv-webif
TEXTSTART="Oscam wurde gestartet!" # your start popup info text
TEXTSTOP="Oscam wurde heruntergefahren!" # your start popup info text
TEXTFAIL="Oscam Fehler!?" # your fail popup info text
TEXTUSB="STOP Datei erkannt!" # your STOP popup info text
WATCHDOG="Oscam wurde durch Watchdog gestartet!"
#
# Configuration End
#
#
# Programcode
# !!! Change at your own risk !!!
#
stop_bootloop()
{
for USB in $TMPDIR/usb/sd* ; do
echo "checking $USB"
[ -e $USB/STOP* ] && samyGOso -A -B -l $SODIR/libAlert.so "TEXT:$TEXTUSB" && exit 1
done
}
case $1 in
start)
stop_bootloop # jump to the bootloop check function
samyGOso -T -B -r -l $OSCAMDIR/libOscam*.so # start the OScam library
sleep 0.5 # wait for 0,5 second
$OSCAMDIR/$BUILD -b -c $OSCAMDIR -t $TMPDIR -w 0 # start OScam
sleep 1
if pidof $BUILD > /dev/null; then # check if oscam is running
samyGOso -A -B -l $SODIR/libAlert.so "TEXT:$TEXTSTART" # send TEXT to TV screen
else
samyGOso -A -B -l $SODIR/libAlert.so "TEXT:$TEXTFAIL" # send TEXT to TV screen
fi
if ! pidof $BUILD > /dev/null; then $OSCAMDIR/$BUILD -b -c $OSCAMDIR -t $TMPDIR -w 0
samyGOso -A -B -l $SODIR/libAlert.so "TEXT:$WATCHDOG" # send TEXT to TV screen
fi
;;
stop)
killall $BUILD # quit oscam
if pidof $BUILD && [ -e $TMPDIR/stopused ] > /dev/null; then # check if oscam is running and stop was used
killall -9 $BUILD # quit oscam immediately
rm $TMPDIR/stopused # remove the used marker
else
touch $TMPDIR/stopused # marks first use of stop
fi
samyGOso -A -B -l $SODIR/libAlert.so "TEXT:$TEXTSTOP" # send TEXT to TV screen
;;
status)
[ -f $TMPDIR/libOscam*.log ] && echo -e "$(head -32 $TMPDIR/libOscam*.log)\n[...]" || echo "Not started"
;;
*)
echo "Usage: $0 {start|stop|status}" 1>&2
exit 0
;;
esac
#
# Programcode End
#