You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							63 lines
						
					
					
						
							994 B
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							63 lines
						
					
					
						
							994 B
						
					
					
				
								#!/bin/sh
							 | 
						|
								
							 | 
						|
								. /etc/init.d/globals
							 | 
						|
								
							 | 
						|
								# Neutrino's exit codes
							 | 
						|
								ERROR=-1
							 | 
						|
								NORMAL=0
							 | 
						|
								SHUTDOWN=1
							 | 
						|
								REBOOT=2
							 | 
						|
								
							 | 
						|
								# if neutrino crashes, just restart it or reboot the box?
							 | 
						|
								REBOOT_ON_ERROR=true
							 | 
						|
								
							 | 
						|
								do_cleanup() {
							 | 
						|
									# remove files created by neutrino
							 | 
						|
									rm -f /tmp/.timer
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								do_shutdown() {
							 | 
						|
									dt -t"SHUTDOWN"
							 | 
						|
									poweroff
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								do_reboot() {
							 | 
						|
									dt -t"REBOOT"
							 | 
						|
									reboot
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								while true; do
							 | 
						|
									do_cleanup
							 | 
						|
								
							 | 
						|
									neutrino; RET=$?
							 | 
						|
									LOGINFO "Neutrino exited with exit code $RET"
							 | 
						|
								
							 | 
						|
									if [ $RET -eq $NORMAL ]; then
							 | 
						|
										# do nothing
							 | 
						|
										break
							 | 
						|
									elif [ $RET -eq $SHUTDOWN ]; then
							 | 
						|
										do_shutdown
							 | 
						|
										break
							 | 
						|
									elif [ $RET -eq $REBOOT ]; then
							 | 
						|
										do_cleanup
							 | 
						|
										do_reboot
							 | 
						|
										break
							 | 
						|
									fi
							 | 
						|
								
							 | 
						|
									dt -t"NEUTRINO: $RET"
							 | 
						|
								
							 | 
						|
									# report errors on external display
							 | 
						|
									if [ -e /tmp/.lcd-* ]; then
							 | 
						|
										echo "0"		> /tmp/lcd/mode_logo
							 | 
						|
										echo "Neutrino"		> /tmp/lcd/service
							 | 
						|
										echo "Error: $RET"	> /tmp/lcd/event
							 | 
						|
									fi
							 | 
						|
								
							 | 
						|
									if $REBOOT_ON_ERROR; then
							 | 
						|
										LOGINFO "Rebooting due to REBOOT_ON_ERROR=true and exit code $RET"
							 | 
						|
										do_reboot
							 | 
						|
										break
							 | 
						|
									fi
							 | 
						|
								
							 | 
						|
									LOGINFO "Restarting neutrino after exit code $RET"
							 | 
						|
								done
							 | 
						|
								
							 |