#!/bin/sh
. /var/etc/autostart/start-config
model=`cat /etc/model`

INPUT=$1
REBOOT=$2
CMD="[start.sh]"star
if  [ ! $debug = 'off' ]; then
	echo $CMD ["$INPUT"] start
fi
if [ $debug = 'full' ]; then
	set -x
fi

startServer() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] start ftp and telnet
	fi
	/usr/sbin/telnetd -l /bin/login
	/etc/init.d/vsftpd start
}

startFsckswap() {
	if [ "$fsckswap" == y ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] fsck swapstick
		fi
		SWAPDEV=`blkid -w /dev/null -c /dev/null -s LABEL | grep -m1 SWAP | cut -d ":" -f1`
 		TYPE=`blkid -w /dev/null -c /dev/null -s TYPE | grep -m1 "$SWAPDEV" | cut -d ":" -f1`
 		if [ "$TYPE" ] && [ "$SWAPDEV" ]; then
			/sbin/fsck."$TYPE" -y "$SWAPDEV"
		fi
	fi
}

startFsckrecord() {
	if [ "$fsckrecord" == y ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] fsck record device
		fi
		RECORDDEV=`blkid -w /dev/null -c /dev/null -s RECORD | grep -m1 SWAP | cut -d ":" -f1`
		TYPE=`blkid -w /dev/null -c /dev/null -s TYPE | grep -m1 "$RECORDDEV" | cut -d ":" -f1`
		if [ "$TYPE" ] && [ "$RECORDDEV" ]; then
			/sbin/fsck."$TYPE" -f -p "$RECORDDEV"
		fi
	fi
}

startMount() {
	if [ -e /var/swap/swapfile ] && [ ! -e /etc/.BAImage ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] remove SWAP fom Flash
		fi
		rm -rf /var/swap/swapfile
	fi
	if [ "$automountshel" = y ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startMount
		fi
		echo [start.sh] automountshel start
		amount
		if [ -e /etc/.BAImage ]; then
			BAamount &
		fi
	fi
}

startPlugload() {
	if [ "$plugload" = y ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start Plugload
		fi
		/var/etc/PlugLoad.sh
	fi
}

startCheckfree() {
	if [ -e /sbin/checkfree ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] checkfree
		fi
		/sbin/checkfree
	fi
}

startLoadmodules() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] load Module
	fi
	LIST=`ls -1 /var/lib/modules`
	for ROUND in $LIST; do
		insmod /var/lib/modules/"$ROUND"
	done
}

startRmemthy() {
	if [ $rmemthy = 'y' ] && [ -e /media/autofs ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start rmemthy
		fi
		LIST=`ls -1 /media/autofs`
		for ROUND in $LIST; do
			LENG=`ls -al /media/autofs/"$ROUND" | wc -l`
			if [ $LENG = "2" ]; then
				if  [ ! $debug = 'off' ]; then
					echo $CMD ["$INPUT"] remove empty folder $LIST / $ROUND
				fi
				rm -rf /media/autofs/"$ROUND"
			fi
		done

		LIST=`ls -1 /media/usb`
		for ROUND in $LIST; do
			LENG=`ls -al /media/usb/"$ROUND" | wc -l`
			if [ $LENG = "2" ]; then
				if  [ ! $debug = 'off' ]; then
					echo $CMD ["$INPUT"] remove empty folder $LIST / $ROUND
				fi
				rm -rf /media/usb/"$ROUND"
			fi
		done

		LENG=`ls -al /media/usb | wc -l`
		if [ $LENG = "2" ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] remove empty folder /media/usb
			fi
			rm -rf /media/usb
		fi
		
		LENG=`ls -al /media/autofs | wc -l`
		if [ $LENG = "2" ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] remove empty folder /media/autofs
			fi
			rm -rf /media/autofs
		fi

	fi
}

startAutodns() {
	if [ $autodns = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start autodns
		fi
		autodns &
	fi
}

startRmplaylist() {
	if [ $playlist = 'y' ] && [ -e /var/usr/local/share/enigma2/playlist.e2pls ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start remove playlist
		fi
		rm /var/usr/local/share/enigma2/playlist.e2pls
	fi
}

startPortmap() {
	if [ $portmap = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start portmap
		fi
		/etc/init.d/portmap start
	fi
}

startBootstop() {
	if [ $bootstop -ne 0 ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start sleep $bootstop s
		fi
		sleep $bootstop
	fi
}

startSamba() {
	IP="`ifconfig | grep inet | grep Bcast | cut -d : -f 2 | sed 's/ Bcast//' | sed 's/ //'`"
	KIP=`grep interfaces /var/etc/smb.conf | sed 's/interfaces = //' | cut -d "/" -f1`
	if [ ! $KIP = $IP ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] set $KIP -> $IP in smb.conf
		fi
		sed -e "s/$KIP/$IP/g" -i /var/etc/smb.conf
	fi

	KIP=`grep interfaces /.smb/smb.conf | sed 's/interfaces = //' | cut -d "/" -f1`
	if [ ! $KIP = $IP ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] set $KIP -> $IP in smb.conf
		fi
		sed -e "s/$KIP/$IP/g" -i /var/root/.smb/smb.conf
	fi

	if [ $sambaserver = 'y' ] && [ -e /var/bin/smbd ] && [ -e /var/bin/nmbd ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start samba
		fi
		HOSTN=`hostname`
	 	if ! grep -q $HOSTN /etc/hosts; then
			echo $IP $HOSTN >> /etc/hosts
		fi
		/var/bin/smbd -D
		sleep 1
		/var/bin/nmbd -D
	fi
}

startNfs() {
	if [ $nfsserver = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start startNfs
		fi
		/etc/init.d/portmap start &
		/etc/init.d/nfs-kernel-server start &
	fi
}

startStickextensions() {
	if grep -q /var/swap /proc/mounts; then
		if [ ! -e /var/swap/automount ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create automount DIR
			fi
			mkdir /var/swap/automount
		fi

		if [ ! -e /var/swap/automount/automounts.xml ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] copy automounts.xml to swap
		  fi
			cp /var/etc/automount/automounts.xml /var/swap/automount/automounts.xml
		fi

		if [ ! -e /var/swap/skins ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create skins DIR
			fi
			mkdir /var/swap/skins
		fi

		if [ ! -e /var/swap/saver ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create swap DIR
			fi
			mkdir /var/swap/saver
		fi

		if [ ! -e /var/swap/mcskins ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create swap DIR
			fi
			mkdir /var/swap/mcskins
		fi

		if [ ! -e /var/swap/images ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create swap DIR
			fi
			mkdir /var/swap/images
		fi

		if [ ! -e /var/swap/extensions ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create extensions DIR
			fi
			mkdir /var/swap/extensions
		fi
		LIST=`ls -1 /var/swap/extensions`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /usr/lib/enigma2/python/Plugins/Extensions/"$ROUND" ]; then
				ln -s "/var/swap/extensions/$ROUND" /usr/lib/enigma2/python/Plugins/Extensions/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/bin ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create bin DIR
			fi
			mkdir /var/swap/bin
		fi
		LIST=`ls -1 /var/swap/bin`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /var/bin/"$ROUND" ]; then
				ln -s "/var/swap/bin/$ROUND" /var/bin/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/fonts ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create swap DIR
			fi
			mkdir /var/swap/fonts
		fi
		LIST=`ls -1 /var/swap/fonts`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /var/usr/share/fonts/"$ROUND" ]; then
				ln -s "/var/swap/fonts/$ROUND" /var/usr/share/fonts/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/modules ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create modules DIR
			fi
			mkdir /var/swap/modules
		fi
		LIST=`ls -1 /var/swap/modules`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /var/lib/modules/"$ROUND" ]; then
				ln -s "/var/swap/modules/$ROUND" /var/lib/modules/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/picon ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create picon DIR
			fi
			mkdir /var/swap/picon
		fi
		if [ ! -e /var/usr/local/share/enigma2/picon ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink picon to swapstick
			fi
			ln -s /var/swap/picon /var/usr/local/share/enigma2/picon
		fi

		if [ ! -e /var/swap/keys ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create keys DIR
			fi
			mkdir /var/swap/keys
		fi
		LIST=`ls -1 /var/swap/keys`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /var/keys/"$ROUND" ]; then
				cp "/var/swap/keys/$ROUND" /var/keys/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/lib ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create lib DIR
			fi
			mkdir /var/swap/lib
		fi
		LIST=`ls -1 /var/swap/lib`
		for ROUND in $LIST; do
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create symlink $ROUND to swapstick
			fi
			if [ ! -e /var/usr/lib/"$ROUND" ]; then
				ln -s "/var/swap/lib/$ROUND" /var/usr/lib/"$ROUND"
			fi
		done

		if [ ! -e /var/swap/boot ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create boot DIR
			fi
			mkdir /var/swap/boot
		fi

		if [ ! -e /var/swap/python2.6 ]; then
			if [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] create python2.6 DIR
			fi
			mkdir /var/swap/python2.6
		fi

	fi
}

startEmu() {
	if [ "$emu" != "off" ] && [ -e /var/emu/`echo "$emu" | cut -d ' ' -f1` ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start $emu
		fi
		/var/emu/$emu &
		if  [ "$iwatch" = "y" ] && [ `echo "$emu" | tr '[A-Z]' '[a-z]' | grep "incubus" | wc -l` != 0 ]; then
			if  [ ! $debug = 'off' ]; then
				echo start incubus_watch
			fi
			/sbin/incubus_watch &
		fi
	fi
}

startRmcrash() {
	if [ $rmcrashlog = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start rmcrashlog
		fi
		rm -rf /media/hdd/enigma2_crash_*.log > /dev/null 2>&1
	fi
}

startWebifport() {
	if [ $webif = 'y' ] && grep -q "config.plugins.Webinterface.interfaces.0.port=81" /etc/enigma2/settings; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] Patching settings with webif port 80
		fi
		sed -e "s!config.plugins.Webinterface.interfaces.0.port=81!config.plugins.Webinterface.interfaces.0.port=80!g" -i /etc/enigma2/settings
	fi
}

startPl12303() {
	if [ -e /lib/modules/usbserial.ko ] && [ -e /lib/modules/pl2303.ko ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] Load pl12303 modul
		fi
		/sbin/insmod /lib/modules/usbserial.ko
		/sbin/insmod /lib/modules/pl2303.ko
	fi
}

startFtdi() {
	if [ -e /lib/modules/usbserial.ko ] && [ -e /lib/modules/pl2303.ko ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] Load ftdi modul
		fi
		/sbin/insmod /lib/modules/usbserial.ko >/dev/null 2>&1
		/sbin/insmod /lib/modules/ftdi.ko
	fi
}

startProfile() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Create Profile
	fi

echo "0.02	PYTHON_START
0.18	LANGUAGE
0.77	LOAD:InfoBar
0.81	LOAD:GUISkin
0.84	LOAD:ElementTree
1.99	LOAD:enigma_skin
2.58	LoadSkin
2.80	LoadSkinDefault
3.07	LoadSkinDefaultDone
3.08	LOAD:Source
3.08	LOAD:GUIComponent
3.47	LOAD:enigma
3.48	LOAD:InfoBarGenerics
3.64	ChannelSelection.py 1
6.86	ChannelSelection.py 2
6.86	ChannelSelection.py 2.1
6.89	ChannelSelection.py 2.2
6.89	ChannelSelection.py 2.3
6.89	ChannelSelection.py 3
6.93	ChannelSelection.py 4
6.95	ChannelSelection.py after imports
7.80	LOAD:InitBar_Components
7.80	LOAD:HelpableScreen
7.81	ParentalControl
7.84	LOAD:Navigation
7.92	LOAD:skin
7.92	LOAD:Tools
7.93	ReloadProfiles
8.01	Twisted
14.61	LOAD:Plugin
14.62	LOAD:Wizard
14.97	misc
14.98	LOAD:ScreenGlobals
15.05	Screen
15.05	Standby,PowerKey
15.06	Scart
15.07	Load:CI
15.09	Load:VolumeControl
15.12	VolumeControl
15.12	Init:skin
15.57	InputDevice
15.58	AVSwitch
15.64	RecordingConfig
15.65	UsageConfig
16.08	keymapparser
16.38	Network
16.44	LCD
16.46	SetupDevices
18.35	RFMod
18.35	Init:CI
18.37	readPluginList
20.65	Init:Session
20.69	wizards
23.03	Init:VolumeControl
23.11	Init:PowerKey
23.13	RunReactor" > /var/tmp/profile

	touch /var/tmp/blacklist
	touch /var/tmp/playlist.e2pls
	touch /var/tmp/whitelist
}

startModule() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Load ntfs and cifs modul
	fi
	/sbin/insmod /lib/modules/fuse.ko
	/sbin/insmod /lib/modules/ntfs.ko
	/sbin/insmod /lib/modules/cifs.ko
}

startRcreboot() {
	if [ "$rcreboot" = 'y' ] && [ "$model" = "ufs910" ]; then
		if [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start RC-Reboot
		fi
		/usr/bin/awk -f /etc/init.d/getfb.awk /dev/input/event0 &
	fi
}

startCrossepg() {
	if [ -e /usr/lib/enigma2/python/Plugins/SystemPlugins/CrossEPG/crossepg/crossepg_epgmove.sh ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start CROSSEPG
		fi
		/usr/lib/enigma2/python/Plugins/SystemPlugins/CrossEPG/crossepg/crossepg_epgmove.sh
	fi
}

startFontsize() {
	if [ "$1" = "reboot" ] || ([ "$1" = "ba" ] && [ -e /var/etc/.firstnet ]); then
		if [ $fontsize = 'big' ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] set fontsize to $fontsize
			fi
			FILE=/var/usr/local/share/enigma2/skin_default.xml
			sed -e 's!<widget font="Regular;17" position="640,130" render="Label" size="350,380" source="ServiceEvent">!<widget font="Regular;22" position="640,130" render="Label" size="350,380" source="ServiceEvent">!g' -i $FILE
			sed -e 's!<widget foregroundColorServiceNotAvail="#5a5a5a" name="list" position="30,74" scrollbarMode="showOnDemand" serviceInfoFont="Regular;17" serviceItemHeight="21" serviceNameFont="Regular;19" serviceNumberFont="Regular;19" size="590,442"/>!<widget foregroundColorServiceNotAvail="#5a5a5a" name="list" position="30,74" scrollbarMode="showOnDemand" serviceInfoFont="Regular;22" serviceItemHeight="26" serviceNameFont="Regular;24" serviceNumberFont="Regular;24" size="590,442"/>!g' -i $FILE
		fi
		if [ $fontsize = 'small' ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] set fontsize to $fontsize
			fi
    	FILE=/var/usr/local/share/enigma2/skin_default.xml
			sed -e 's!<widget font="Regular;22" position="640,130" render="Label" size="350,380" source="ServiceEvent">!<widget font="Regular;17" position="640,130" render="Label" size="350,380" source="ServiceEvent">!g' -i $FILE
			sed -e 's!<widget foregroundColorServiceNotAvail="#5a5a5a" name="list" position="30,74" scrollbarMode="showOnDemand" serviceInfoFont="Regular;22" serviceItemHeight="26" serviceNameFont="Regular;24" serviceNumberFont="Regular;24" size="590,442"/>!<widget foregroundColorServiceNotAvail="#5a5a5a" name="list" position="30,74" scrollbarMode="showOnDemand" serviceInfoFont="Regular;17" serviceItemHeight="21" serviceNameFont="Regular;19" serviceNumberFont="Regular;19" size="590,442"/>!g' -i $FILE
		fi
	fi
}

startFonts() {
	if [ ! -e /var/usr/share/fonts/default.ttf ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] restore default fonts
		fi
		cp /var/usr/share/fonts/backup-default.ttf /var/usr/share/fonts/default.ttf
	fi
}

startLcdlogo() {
	if [ "$model" = "ufs910" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start AAF LCD LOGO
		fi
		/bin/vfdctl -x /bin/aaf_mod.vfdx &
	fi
}

startRedbutton() {
	if [ "$model" = "ufs910" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] stop red button
		fi
		echo "B" > /dev/ttyAS1
	fi
}

startBa() {
	if [ -e /var/baroot/ba/bainit ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start bainit
		fi
		mkdir /tmp/badevice
		mount --bind /var/badevice /tmp/badevice
		if [ "$model" = "ufs910" ]; then
			if [ `grep /dev/mtdblock3 /proc/mounts | tail -n 1 | wc -l` -eq 1 ]; then
				/var/baroot/ba/bainit > /var/ba.log 2>&1
			fi
		elif [ "$model" = "ufs922" ]; then
			if [ `grep /dev/mtdblock3 /proc/mounts | tail -n 1 | wc -l` -eq 1 ]; then
				if [ -e /var/baroot/.e2flash ]; then
					/var/baroot/ba/bainit > /var/ba.log 2>&1
				fi
			fi
		fi
		umount /tmp/badevice
		rmdir /tmp/badevice 
	fi
}

startBootdelay() {
	if [ -e /var/etc/.bootdelay ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start set bootdelay 1
		fi
		fw_setenv bootdelay 1
		rm /var/etc/.bootdelay
	fi
}

startNet() {
	if [ -e /var/etc/.firstnet ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startNet first boot
		fi

		if [ "$model" = "ufs910" ]; then
			HELP=`cat /proc/cmdline | tr " " "\n" | grep "^ip=" | sed 's/^ip=//'`
			GW=`echo "$HELP" | cut -d ":" -f 3`
			IP=`echo "$HELP" | cut -d ":" -f 1`
			MASK=`echo "$HELP" | cut -d ":" -f 4`
		else
			HELP=`fw_printenv`  
			GW=`echo "$HELP" | grep gateway= | sed 's/gateway=//'`
			IP=`echo "$HELP" | grep ipaddr= | sed 's/ipaddr=//'`
			MASK=`echo "$HELP" | grep netmask= | sed 's/netmask=//'`
		fi

		if [ -z "$IP" ]; then IP="192.168.0.1"; fi
		if [ -z "$MASK" ]; then MASK="255.255.255.0"; fi
		if [ -z "$GW" ]; then GW="192.168.0.1"; fi
		DNS=$GW
		echo "auto eth0" > /var/etc/network/interfaces
		echo "iface eth0 inet static" >> /var/etc/network/interfaces
		echo "	address $IP" >> /var/etc/network/interfaces
		echo "	netmask $MASK" >> /var/etc/network/interfaces
		echo "	gateway $GW" >> /var/etc/network/interfaces
		echo "nameserver $DNS" > /var/etc/resolv.conf
		rm /var/etc/.firstnet
	else
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startNet
		fi
		
		ethcat=`cat /var/etc/network/interfaces`
		if echo -e "$ethcat" | grep -q "inet static"; then
			TYPE="STATIC IP"
		else
			TYPE="DHCP IP"
		fi
		if [ "$TYPE" == "STATIC IP" ]; then
			IP=`echo -e "$ethcat" | sed s/"^\s*"// | sed s/" \+"/" "/g | grep -m1 "^address" | cut -d " " -f2`
			GW=`echo -e "$ethcat" | sed s/"^\s*"// | sed s/" \+"/" "/g | grep -m1 "^gateway" | cut -d " " -f2`
			MASK=`echo -e "$ethcat" | sed s/"^\s*"// | sed s/" \+"/" "/g | grep -m1 "^netmask" | cut -d " " -f2`
	 	else
	 		IP=`ifconfig eth0 | grep -m1 "inet addr" | sed s/"^\s*"// | sed s/" \+"/" "/g | cut -d " " -f2 | cut -d ":" -f2`
	 		GW=`route -n | grep -m1 "^0.0.0.0" | sed s/" \+"/" "/g | cut -d " " -f2`
			MASK=`ifconfig eth0 | grep -m1 "inet addr" | sed s/"^\s*"// | sed s/" \+"/" "/g | cut -d " " -f2 | cut -d ":" -f2`
	 	fi
	 	DNS=`cat /etc/resolv.conf | grep nameserver | cut -d" " -f2`
	 	if [ -z "$DNS" ]; then DNS="no dns on firstboot"; fi
	fi

 	/etc/init.d/networking start "$IP" "$GW" "$MASK"

	if [ $showip = 'status' ]; then
		echo "$TYPE" > /dev/dbox/fp0 &
	fi
	if [ $showip = 'ip' ]; then
		echo $IP > /dev/dbox/fp0 &
	fi
	echo -e "IP-ADDRESSE: $IP\nNETMASKE: $MASK\nDNS-SERVER: $DNS\nGATEWAY: $GW" >> /tmp/.infobox
	echo $GW > /var/etc/default_gw
}

startShowinfo() {
	if [ $showiptv = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startShowinfo
		fi
		VERSION=`cat /etc/version`
		a=0
		while [ ! -e /tmp/.swapready ]; do
			sleep 1
			a=$(($a+1))
			if [ $a -gt 10 ]; then break; fi
		done
		while read line; do
			param="$param \"$line\""
		done < /tmp/.infobox
		if [ ! -z "$param" ]; then
			(
				eval infobox 5 "BOOT-INFO" $param \"--------------------------------\" \"VERSION: $VERSION\"
				touch /tmp/.showinfoready
			)&
		fi
		rm -f /tmp/.swapready
	fi
}

startSystemdown() {
	sync
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Swapoff
	fi
	swap swapfileoff
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Stop Emu
	fi
	killall -9 `grep "emu=" /var/etc/autostart/start-config | cut -d \" -f 2 | cut -d " " -f0`
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Umount Disks
	fi
	devlist=`cat /proc/diskstats | cut -c 11- | cut -d " " -f1 | grep "sd[a-z][0-9]"`
	for device in $devlist; do
		echo $CMD ["$INPUT"] umount -fl /dev/"$device"
		umount -fl /dev/"$device"
	done
	startFsckrecord
	startFsckswap
}

startReboot() {
	if [ $REBOOT == "1" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] SHUTDOWN
		fi
		/sbin/fuser -k /dev/dvb/adapter0/frontend0
		echo "SHUTDOWN" > /dev/dbox/fp0
		/var/etc/boot/poweroff.sh
		if [ "$model" = "ipbox910" ] || [ "$model" = "ipbox900" ] || [ "$model" = "ipbox91" ] || [ "$model" = "ipbox9000" ]; then
			sleep 5
			cubefpctl --poweroff
		fi
		startSystemdown
	elif [ $REBOOT == "2" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] REBOOT
		fi
		/sbin/fuser -k /dev/dvb/adapter0/frontend0
		echo "REBOOT" > /dev/dbox/fp0
		/var/etc/boot/poweroff.sh
		if [ "$model" = "ipbox910" ] || [ "$model" = "ipbox900" ] || [ "$model" = "ipbox91" ] || [ "$model" = "ipbox9000" ]; then
			sleep 5
			cubefpctl --reboot
		fi
		startSystemdown			
	elif [ $REBOOT == "3" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] E2 RESTART
		fi
		/sbin/fuser -k /dev/dvb/adapter0/frontend0
		echo "E2 RESTART" > /dev/dbox/fp0
		if [ "$model" = "ufs922" ]; then
			echo $CMD ["$INPUT"] setvolume
			python /sbin/setvolume.pyc &
		fi
	else
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] ERROR
		fi
		sleep $errorstop
		/sbin/fuser -k /dev/dvb/adapter0/frontend0
		echo "ERROR REBOOT" > /dev/dbox/fp0
		if [ "$e2errorboot" != "y" ]; then
			echo "." >> /var/etc/.error
			/var/etc/boot/poweroff.sh
			startSystemdown
		fi
	fi
}

startFirst() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Boot first
	fi
	touch /var/etc/.first
}

startRm_first_error() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Remove first and error
	fi
	rm -f /var/etc/.first
	rm -f /var/etc/.error
}

startHddicon() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] Set HDD Icon
	fi
	if [ -e /tmp/.recorddev ]; then
		vfdctl +hdd
	else
		if [ -e /etc/.BAImage ]; then
			if grep -q "/hdd" /proc/mounts; then
				vfdctl +hdd
			fi	
		fi		
	fi
}

startMini() {
	if [ "$model" = "ufs910" ] && [ ! -e /etc/.usbimage ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startMini
		fi
		minicheck=`dd if=/dev/mtdblock6 bs=1 skip=32 count=16 | grep "mini U-boot" | wc -l`
		if [ $minicheck = 1 ]; then
			miniflashver=`dd if=/dev/mtdblock6 bs=1 skip=45 count=3 | tr -d "."`
			if [ "$miniflashver" == "xt2" ]; then miniflashver=10; fi
			if [ -e /var/bin/miniuboot ]; then
				minifilever=`dd if=/var/bin/miniuboot bs=1 skip=45 count=3 | tr -d "."`
				if [ "$minifilever" == "xt2" ]; then minifilever=10; fi
				if [ $minifilever -gt $miniflashver ]; then
					infobox 4 Info "Updating miniuboot from r${miniflashver:0:$((${#miniflashver}-1))}.${miniflashver:$((${#miniflashver}-1)):1} to r${minifilever:0:$((${#minifilever}-1))}.${minifilever:$((${#minifilever}-1)):1}"
					/var/bin/flashcp -v /var/bin/miniuboot /dev/mtd6
					rm -f /var/bin/flashcp /var/bin/miniuboot
				elif [ -e /var/bin/miniuboot ]; then
					infobox 3 Info "Skipping install miniuboot - installed version is same or newer"
					rm -f /var/bin/flashcp /var/bin/miniuboot
				fi
			fi
		elif [ -e /var/bin/miniuboot ]; then
			minifilever=`dd if=/var/bin/miniuboot bs=1 skip=45 count=3`
			if [ "$minifilever" == "xt2" ]; then minifilever="1.0"; fi
			infobox 15025 Info "Installing miniuboot r$minifilever" &
			/var/bin/flashcp -v /var/bin/miniuboot /dev/mtd6
			killall -4 infobox
			fw_setenv ipaddr `cat /var/etc/network/interfaces | sed s/"^\s*"// | sed s/" \+"/" "/g | grep "^address" | cut -d " " -f2`
			fw_setenv serverip `cat /var/etc/network/interfaces | sed s/"^\s*"// | sed s/" \+"/" "/g | grep "^gateway" | cut -d " " -f2`
			fw_setenv gateway `cat /var/etc/network/interfaces | sed s/"^\s*"// | sed s/" \+"/" "/g | grep "^gateway" | cut -d " " -f2`
			fw_setenv gatewayip `cat /var/etc/network/interfaces | sed s/"^\s*"// | sed s/" \+"/" "/g | grep "^gateway" | cut -d " " -f2`
			fw_setenv ethaddr `ifconfig | grep HWaddr | sed "s/ \+/ /g" | cut -d " " -f5`
			fw_setenv netmask `ifconfig | grep Bcast | cut -d ":" -f4`
			fw_setenv bootcmd 'bootm a0030000'
			killall -4 infobox
			fw_setenv bootdesc_0 '----Flash----'
			fw_setenv bootcmd_0 'run bootargs_0; bootm a0040000'
			fw_setenv bootargs_0 'set bootargs console=ttyAS0,115200 root=/dev/mtdblock2 ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:kathrein:eth0:off mem=64m coprocessor_mem=4m@0x10000000,4m@0x10400000 rootdelay=0 nwhwconf=device:eth0,hwaddr:${ethaddr} init=/bin/devinit'
			fw_setenv bootdesc_9 '-USB-1-Speed-'
			#fw_setenv bootcmd_9 'usb reset;ext2load usb 0:2 a5000000 /boot/uImage;run bootargs_9;bootm a5000000'
			fw_setenv bootcmd_9 'run bootargs_9;bootm a0040000'
			fw_setenv bootargs_9 'set bootargs console=ttyAS0,115200 root=/dev/sda2 rw ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:kathrein:eth0:off mem=64m coprocessor_mem=4m@0x10000000,4m@0x10400000 rootdelay=6 nwhwconf=device:eth0,hwaddr:${ethaddr} init=/bin/devinit'
			killall -4 infobox
			fw_setenv bootdesc_8 '----USB-2----'
			fw_setenv bootcmd_8 'usb reset;ext2load usb 0:3 a5000000 /boot/uImage;run bootargs_8;bootm a5000000'
			fw_setenv bootargs_8 'set bootargs console=ttyAS0,115200 root=/dev/sda3 rw ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:kathrein:eth0:off mem=64m coprocessor_mem=4m@0x10000000,4m@0x10400000 rootdelay=6 nwhwconf=device:eth0,hwaddr:${ethaddr} init=/bin/devinit'
			fw_setenv bootdesc_7 '----USB-3----'
			fw_setenv bootcmd_7 'usb reset;ext2load usb 0:4 a5000000 /boot/uImage;run bootargs_7;bootm a5000000'
			fw_setenv bootargs_7 'set bootargs console=ttyAS0,115200 root=/dev/sda4 rw ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:kathrein:eth0:off mem=64m coprocessor_mem=4m@0x10000000,4m@0x10400000 rootdelay=6 nwhwconf=device:eth0,hwaddr:${ethaddr} init=/bin/devinit'
			rm -f /var/bin/flashcp /var/bin/miniuboot
			killall -4 infobox
			killall infobox
		fi
	fi
}

startSwap() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] startSwap
	fi
	swap
}

startChecklink() {
	netlink=0
	if [ "$model" = "ufs910" ]; then
		if grep -q up /sys/class/net/eth0/operstate; then netlink=1; fi
	else
		INETCK=`ping -c1 google.de | wc -l`
		if [ $INETCK = "6" ]; then netlink=1; fi
	fi
}

startGetbootvid() {
	if [ -e /var/etc/.getbootvid ]; then
		startChecklink
		if grep -q /var/swap /proc/mounts && [ $netlink -eq 1 ]; then
			if [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] startgetbootvid
			fi
			infobox 5 Info "Try to download Boot-/Shutdownvideo. Please wait!" &
			echo "Load Bootvideo" > /dev/dbox/fp0
			if [ ! -e /var/swap/boot ]; then
				if [ ! $debug = 'off' ]; then
					echo $CMD ["$INPUT"] create boot DIR
				fi
				mkdir /var/swap/boot
			fi
			rm -f /var/swap/boot/bootvideo.mkv /var/swap/boot/bootvideo.mvi /var/swap/boot/poweroffvideo.mkv
			sync
			cd /var/swap/boot
			wget.info `cat /var/etc/ipkg/official-feed.conf | cut -d " " -f3`/boot/bootvideo.mkv
			if [ $? == 0 ]; then
				wget.info `cat /var/etc/ipkg/official-feed.conf | cut -d " " -f3`/boot/bootvideo.mvi
				wget.info `cat /var/etc/ipkg/official-feed.conf | cut -d " " -f3`/boot/poweroffvideo.mkv
			fi
		fi
		rm -f /var/etc/.getbootvid
		sync
	fi
}

startRestore() {
	if [ -e /var/swap/backup/.firstrun ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startRestore from swapstick
		fi
		infobox 15013 RESTORE "Restore from swapstick start !" &
		if [ -e /var/swap/backup/bin/update ]; then
			rm -f /var/swap/backup/bin/update
		fi
		if [ -e /var/swap/backup/bin/miniuboot ]; then
			rm -f /var/swap/backup/bin/miniuboot
		fi
		if [ -e /var/swap/backup/bin/flashcp ]; then
			rm -f /var/swap/backup/bin/flashcp
		fi
		if [ -e /var/swap/backup/enigma2/bouquets.tv ]; then
			rm -f /etc/enigma2/*.tv
		fi
		if [ -e /var/swap/backup/enigma2/bouquets.radio ]; then
			rm -f /etc/enigma2/*.radio
		fi
		cp -a /var/swap/backup/etc/* /var/etc/; killall -4 infobox
		cp -a /var/swap/backup/keys/* /var/keys/; killall -4 infobox
		cp -a /var/swap/backup/bin/* /var/bin/; killall -4 infobox
		cp -a /var/swap/backup/network/* /var/etc/network/; killall -4 infobox
		cp -a /var/swap/backup/enigma2/* /etc/enigma2/; killall -4 infobox
		cp -R /var/swap/backup/po/* /usr/local/share/enigma2/po/; killall -4 infobox
		cp -a /var/swap/backup/countries/* /usr/local/share/enigma2/countries/; killall -4 infobox
		cp -a /var/swap/backup/autostart/* /var/etc/autostart/; killall -4 infobox
		rm -r /var/swap/backup/.firstrun; killall -4 infobox
		sleep 2
		sync
		killall infobox
	fi
	if [ -e /media/hdd/backup/.firstrun ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startRestore from hdd
		fi
		infobox 15013 RESTORE "Restore from hdd start !" &
		if [ -e /media/hdd/backup/bin/update ]; then
			rm -f /media/hdd/backup/bin/update
		fi
		if [ -e /media/hdd/backup/bin/miniuboot ]; then
			rm -f /media/hdd/backup/bin/miniuboot
		fi
		if [ -e /media/hdd/backup/bin/flashcp ]; then
			rm -f /media/hdd/backup/bin/flashcp
		fi
		rm -f /usr/local/share/enigma2/*.tv /usr/local/share/enigma2/*.radio
		cp -a /media/hdd/backup/etc/* /var/etc/; killall -4 infobox
		cp -a /media/hdd/backup/keys/* /var/keys/; killall -4 infobox
		cp -a /media/hdd/backup/bin/* /var/bin/; killall -4 infobox
		cp -a /media/hdd/backup/network/* /var/etc/network/; killall -4 infobox
		cp -a /media/hdd/backup/enigma2/* /etc/enigma2/; killall -4 infobox
		cp -R /media/hdd/backup/po/* /usr/local/share/enigma2/po/; killall -4 infobox
		cp -a /media/hdd/backup/countries/* /usr/local/share/enigma2/countries/; killall -4 infobox
		cp -a /media/hdd/backup/autostart/* /var/etc/autostart/; killall -4 infobox
		rm -r /media/hdd/backup/.firstrun; killall -4 infobox
		sleep 2
		sync
		killall infobox
	fi
}

startSetvol() {
	if [ "$model" = "ufs922" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startSetvol
		fi
		echo $CMD ["$INPUT"] setvolume
		python /sbin/setvolume.pyc &
	fi
}

startSaveepg() {
	if [ -e /media/hdd/epg.dat ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] start epg hdd save
		fi
		echo "Save EPG" > /dev/dbox/fp0
		if [ -e /etc/.BAImage ]; then
			rm -f /backup/epg.dat
			cp /media/hdd/epg.dat /backup/epg.dat
		else	
			rm -f /media/hdd/epg.dat.sav
			cp /media/hdd/epg.dat /media/hdd/epg.dat.sav
		fi	
		sync
	fi
}

startRestoreepg() {
	if [ -e /etc/.BAImage ]; then
		if [ -e /backup/epg.dat ]; then
			cp /backup/epg.dat /media/hdd/epg.dat
			sync
		fi	
	else
		if [ -e /media/hdd/epg.dat.sav ] && [ ! -e /media/hdd/epg.dat ]; then
			if  [ ! $debug = 'off' ]; then
				echo $CMD ["$INPUT"] start epg restore
			fi
			echo "Restore EPG" > /dev/dbox/fp0
			cp /media/hdd/epg.dat.sav /media/hdd/epg.dat
			sync
		fi
	fi	
}

startSwapepg() {
	if [ ! -L /media/hdd ]; then
		if ! grep -q /media/hdd /proc/mounts; then
			if grep -q /var/swap /proc/mounts; then
				if  [ ! $debug = 'off' ]; then
					echo $CMD ["$INPUT"] start epg on swap
				fi
				mv /var/swap/movie /var/swap/movie.$$ 2>/dev/null
				mv /var/swap/movies /var/swap/movies.$$ 2>/dev/null
				touch /tmp/.swapepg
				mount --bind /var/swap /media/hdd
			fi
		fi
	fi
}

startSysctl() {
	if [ "$model" = "ufs910" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startSysctl
		fi
		echo 0 > /proc/sys/net/ipv4/tcp_timestamps
		echo 0 > /proc/sys/net/ipv4/tcp_sack
	fi
}

startFan() {
# Start Fan
	if [ "$model" = "ufs922" ]; then
		echo "Set Fan Speed"
		fanspeed=`grep config.Fan.speed /etc/enigma2/settings | cut -d "=" -f 2`
		if [ $fanspeed ]; then
			if [ $fanspeed = "0" ];then
				echo "115" >/proc/stb/fan/fan_ctrl
			fi
			if [ $fanspeed = "1" ];then
				echo "130" >/proc/stb/fan/fan_ctrl
			fi
			if [ $fanspeed = "2" ];then
				echo "145" >/proc/stb/fan/fan_ctrl
			fi
			if [ $fanspeed = "3" ];then
				echo "155" >/proc/stb/fan/fan_ctrl
			fi
			if [ $fanspeed = "4" ];then
				echo "170" >/proc/stb/fan/fan_ctrl
			fi
		else
			# if no value found set to 1500rpm
			echo "170" >/proc/stb/fan/fan_ctrl
		fi
	fi
}

startLoadpartition() {
	if [ $loadpartition = 'y' ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startLoadpartition
		fi
		if [ "$1" ]; then
			hdparm -z "/dev/$1"
		else
			for dev in sda sdb sdc sde sdf sdg; do
				hdparm -z "/dev/$dev"
			done
		fi
		sleep 2
	fi
}

startAutoFS() {
	if [ -e /var/etc/autofs ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startAutoFS
		fi
		if grep -q "True" /var/etc/autofs; then
			/etc/init.d/autofs start &
		fi
	fi
}

startRepair() {
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] startRepair
	fi
	rm -f /media/hdd/epg.dat
	rm -f /media/hdd/epg.dat.sav
	
	resolvsize=`ls -l /var/etc/resolv.conf 2>/dev/null | cut -c 30-42`
	if [ ! -z "$resolvsize" ] && [ $resolvsize -gt 2048 ]; then
		rm -f /var/etc/resolv.conf
	fi
	
	sed "/config.skin.primary_skin=/d" -i /etc/enigma2/settings
	if [ -L /var/usr/local/share/enigma2/skin_default ]; then
		rm -f /var/usr/local/share/enigma2/skin_default
		ln -s /usr/local/share/skin_default /var/usr/local/share/enigma2/skin_default
	fi
	if [ -L /var/usr/local/share/enigma2/skin_default.xml ]; then
		rm -f /var/usr/local/share/enigma2/skin_default.xml
		ln -s /usr/local/share/skin_default.xml /var/usr/local/share/enigma2/skin_default.xml
	fi
	if [ -L /var/usr/local/share/enigma2/skin.xml ]; then
		rm -f /var/usr/local/share/enigma2/skin.xml
		ln -s /usr/local/share/skin.xml /var/usr/local/share/enigma2/skin.xml
	fi
	
	infobox 9999 INFO "FSCK" "Soll   ein   Filesystemcheck   durchgefuehrt   werden   ?" " " "OK   =   Check durchfuehren" "Exit   =   Keine Check durchfuehren" &
	echo "FB - ABFRAGE" > /dev/dbox/fp0
	abfrage /dev/input/event0; ret=$?
	killall infobox
	if [ $ret -eq 0 ]; then
		swap swapfileoff
		devlist=`cat /proc/diskstats | cut -c 11- | cut -d " " -f1 | grep "sd[a-z][0-9]"`
		for device in $devlist; do
			echo $CMD ["$INPUT"] umount -fl /dev/"$device"
			umount -fl /dev/"$device"
		done
		rm -f /tmp/.swapdev
		rm -f /tmp/.recorddev
		startFsckrecord
		startFsckswap
		amount
		swap
	fi
}

startOnlineupdate() {
	#Hole Imagelist
	python /sbin/onlineupdate.pyc getlist
	lastimg=`ls -1 /tmp/online | grep _"$model"_ | grep _FULL_ | tail -n1`
	if [ ! -z "$lastimg" ]; then
		infobox 9999 INFO "Gefundenes Image:" "$lastimg" " " "OK   =   Update durchfuehren" "Exit   =   Keine Update durchfuehren" &
		echo "FB - ABFRAGE" > /dev/dbox/fp0
		abfrage /dev/input/event0; ret=$?
		killall infobox
		if [ $ret -eq 0 ]; then
			#Online Update
			python /sbin/onlineupdate.pyc update $model $lastimg
			aaa=1
		fi
	else
		infobox 3 INFO "Leider   wurde   keine   Image   am   Server   gefunden."
	fi
}

startHaltonerror() {
	if [ "$repairmodus" != "0" ] && [ -e /var/etc/.error ]; then
		if [ "$repairmodus" = "2" ] && [ `cat /var/etc/.error | wc -l` -lt 2 ]; then return; fi
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startHaltonerror
		fi
		a=0
		while [ ! -e /tmp/.showinfoready ]; do
			sleep 1
			a=$(($a+1))
			if [ $a -gt 10 ]; then break; fi
		done
		if [ ! -e /etc/.BAImage ]; then
			infobox 9999 INFO "Ein   Fehler   wurde   beim   letzten   REBOOT   festgestellt." "Mit   TELNET   koennen   Reperaturen   durchgefuehrt   werden." "ErrorLog   in   /media/hdd   wenn   rmcrashlog   im   Panel   deaktiviert." " " "OK   =   Fortsetzen" "ROT   =   Reparieren (bei Bootschleife)" "BLAU   =   Online Update" &
		else
			infobox 9999 INFO "Ein   Fehler   wurde   beim   letzten   REBOOT   festgestellt." "Mit   TELNET   koennen   Reperaturen   durchgefuehrt   werden." "ErrorLog   in   /media/hdd   wenn   rmcrashlog   im   Panel   deaktiviert." " " "OK   =   Fortsetzen" "ROT   =   Reparieren (bei Bootschleife)" &
		fi
		rm -f /var/etc/.error
		echo "FB - ABFRAGE" > /dev/dbox/fp0
		abfrage /dev/input/event0; ret=$?
		killall infobox
		if [ $ret -eq 2 ] && [ ! -e /etc/.BAImage ]; then
			startOnlineupdate
		fi
		if [ $ret -eq 3 ]; then
			startRepair
		fi
	fi
	rm -f /tmp/.showinfoready
}

startWorkaround() {
	if [ "$model" = "ipbox910" ] || [ "$model" = "ipbox900" ] || [ "$model" = "ipbox91" ] || [ "$model" = "ipbox9000" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startWorkaround
		fi
		/var/bin/rem &
	fi
}

startTimefix() {
	if [ "$model" = "ipbox910" ] || [ "$model" = "ipbox900" ] || [ "$model" = "ipbox91" ] || [ "$model" = "ipbox9000" ]; then
		if  [ ! $debug = 'off' ]; then
			echo $CMD ["$INPUT"] startTimefix
		fi
		/var/bin/ntpdate ptbtime1.ptb.de
		cubefpctl --syncfptime 
		ln -sf /usr/share/zoneinfo/CET /var/etc/localtime
	fi
}	 

startSetvolume() {
	#startSetvolume 0-100, ohne Parameter wird settings genommen
	if  [ ! $debug = 'off' ]; then
		echo $CMD ["$INPUT"] startSetvolume
	fi
	if [ "$1" ]; then 
		vol=$1
	else
		vol=`grep config.audio.volume= /etc/enigma2/settings | cut -d = -f2`
	fi
	if [ -z $vol ]; then vol=30; fi
	newvol=$((63-(($vol*63)/100)))
	echo $newvol > /proc/stb/avs/0/volume
}

startLink() {
	if [ ! -e /usr/local/share/enigma2/timers.xml ]; then	
		ln -s /etc/enigma2/timers.xml /usr/local/share/enigma2/timers.xml
	fi
}	 

if [ $1 = "first" ] ;then
	startSysctl
	startFirst
	startAutoFS
	startLink
elif [ $1 = "ba" ] ;then
	startBootstop
	startLoadpartition
	startMount
	startBa
	startSwap
	startSwapepg
	startRestoreepg
	startRestore
	startFontsize ba
	startWorkaround
	(startNet; startShowinfo) &
elif [ $1 = "e2" ] ;then
	startRcreboot
	startPlugload
	startEmu
	startFan
	startProfile &
	startFonts
	startCrossepg
	startLcdlogo
	startRedbutton
	startSetvol
	startHaltonerror
	startPl12303
	startFtdi
	startTimefix
elif [ $1 = "last" ] ;then
	sleep 10
	startRm_first_error
	startStickextensions &
	startHddicon
	startWebifport
	startLoadmodules &
	startAutodns
	startRmplaylist
	startRmcrash
	startSamba &
	startNfs
elif [ $1 = "reboot" ] ;then
	startSaveepg
	startMini
	startGetbootvid
	startFontsize reboot
	startReboot
	startBootdelay
	startRmemthy
fi

exit
