|  | @ -1,6 +1,6 @@ | 
			
		
	
		
		
			
				
					|  |  | #!/bin/sh |  |  | #!/bin/sh | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | touch /tmp/norestart |  |  | . /etc/init.d/globals | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | if [ -e /var/etc/.coredump ]; then |  |  | if [ -e /var/etc/.coredump ]; then | 
			
		
	
		
		
			
				
					|  |  | 	ulimit -c unlimited |  |  | 	ulimit -c unlimited | 
			
		
	
	
		
		
			
				
					|  | @ -9,33 +9,55 @@ fi | 
			
		
	
		
		
			
				
					|  |  | # uncomment for gstreamer debugging |  |  | # uncomment for gstreamer debugging | 
			
		
	
		
		
			
				
					|  |  | #export GST_DEBUG=4 |  |  | #export GST_DEBUG=4 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | until neutrino; do |  |  | # if neutrino crashes, just restart it or reboot the box? | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 	RET=$? |  |  | REBOOT_ON_ERROR=false | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | 	# shutdown |  |  | do_cleanup() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 	if [ $RET -eq 1 ]; then |  |  | 	# remove files created by neutrino | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 		touch /tmp/.halt |  |  | 	rm -f /tmp/.reboot /tmp/.timer | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | do_shutdown() { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	echo "Shutdown ..." > /dev/dbox/oled0 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	poweroff | 
			
		
	
		
		
			
				
					|  |  |  |  |  | } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | do_reboot() { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	echo "Reboot ..." > /dev/dbox/oled0 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	reboot | 
			
		
	
		
		
			
				
					|  |  |  |  |  | } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | while true; do | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	do_cleanup | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	neutrino; RET=$? | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	LOGINFO "Neutrino exited with exit code $RET" | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	if [ $RET -eq 0 ]; then | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 		# do nothing | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 		break | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	elif [ $RET -eq 1 ]; then | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 		do_shutdown | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 		break | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	elif [ $RET -eq 2 ]; then | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 		do_reboot | 
			
		
	
		
		
			
				
					|  |  | 		break |  |  | 		break | 
			
		
	
		
		
			
				
					|  |  | 	fi |  |  | 	fi | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 	echo "Neutrino exited with exit code $RET" |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 	echo "Neutrino: $RET" > /dev/dbox/oled0 |  |  | 	echo "Neutrino: $RET" > /dev/dbox/oled0 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	# report errors on external display | 
			
		
	
		
		
			
				
					|  |  | 	if [ -e /tmp/.lcd-usbdev?.? ]; then |  |  | 	if [ -e /tmp/.lcd-usbdev?.? ]; then | 
			
		
	
		
		
			
				
					|  |  | 		echo "0"		> /tmp/lcd/mode_logo |  |  | 		echo "0"		> /tmp/lcd/mode_logo | 
			
		
	
		
		
			
				
					|  |  | 		echo "Neutrino"		> /tmp/lcd/service |  |  | 		echo "Neutrino"		> /tmp/lcd/service | 
			
		
	
		
		
			
				
					|  |  | 		echo "Error: $RET"	> /tmp/lcd/event |  |  | 		echo "Error: $RET"	> /tmp/lcd/event | 
			
		
	
		
		
			
				
					|  |  | 	fi |  |  | 	fi | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | 	while [ -e /tmp/norestart ]; do # for debugging: stop the restart loop |  |  | 	if $REBOOT_ON_ERROR; then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 		sleep 1; |  |  | 		LOGINFO "Rebooting due to REBOOT_ON_ERROR=true and exit code $RET" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 	done |  |  | 		do_reboot | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | done |  |  | 		break | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 	fi | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | if [ -e /tmp/.reboot ]; then # gets created by neutrino |  |  | 	LOGINFO "Restarting neutrino after exit code $RET" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 	echo "Reboot ..." > /dev/dbox/oled0 |  |  | done | 
			
				
				
			
		
	
		
		
			
				
					|  |  | 	reboot |  |  |  | 
			
		
	
		
		
			
				
					|  |  | elif [ -e /tmp/.halt ]; then |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 	echo "Shutdown ..." > /dev/dbox/oled0 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 	poweroff |  |  |  | 
			
		
	
		
		
			
				
					|  |  | fi |  |  |  | 
			
		
	
		
		
	
		
		
	
	
		
		
			
				
					|  | 
 |