#!/bin/sh
#### "***********************************************"
#### "*       ..:: Script by MOHAMED_OS ::..        *"
#### "*  Support: https://github.com/MOHAMED19OS    *"
#### "*       E-Mail: mohamed19eng@gmail.com        *"
#### "***********************************************"
LOG_FILE="/tmp/camstart.log"
CAMNAME="oscamicamnew"

case "$1" in
start)
    ulimit 1024
	
    /usr/bin/oscamicamnew  --config-dir /usr/keys --daemon --pidfile /tmp/oscamicamnew.pid --restart 2

	#CAM_UP_OUTPUT="$(/usr/bin/oscamicamnew  --config-dir /usr/keys --daemon --pidfile /tmp/oscamicamnew.pid --restart 2 --utf8 2>&1)"
    
					#if [ $? -gt 0 ]; then
					#	ERROR_MESSAGE="Fehler beim Starten der Oscam: $CAM_UP_OUTPUT"
					#	echo "$ERROR_MESSAGE" >> $LOG_FILE
					#	$WGET -O -q "http://localhost/web/message?text=${MESSAGE// /%20}&type=0&timeout=5" /dev/null
					#	sleep 3
					#	$WGET -O -q "http://localhost/web/message?text=Cam+not+Startet+Error!!!+---+logfile+---+tmp/OscamStartError.log&type=1&timeout=10" /dev/null
					#	sleep 10
					#fi
}
    ;;
stop)
    killall -9 ${CAMNAME} 2>/dev/null
    ;;
restart | reload)
    $0 stop
    sleep 1
    $0 start
    ;;
version)
    echo "${CAMNAME}"
    ;;
info)
    echo "${CAMNAME}"
    ;;
*)
    echo "Usage: $0 start|stop|restart"
    exit 1
    ;;
esac
exit 0
