#!/bin/bash startcount=0 failcount=0 while /bin/true ; do # this will try dual-head if two heads are found, # and fall back to single-head; if X keeps crashing, # then bail out and let init temporarily disable # autologin startcount=$((startcount+1)) /opt/bin/xinit-wrapper /opt/bin/kiosk.xinit || { # in case X crashes forever, it should be at least stoppable failcount=$((failcount+1)) chvt 1 echo >/dev/tty1 echo "Graphics subsystem failed to start," >/dev/tty1 echo "re-trying in 10 seconds... (attempt $failcount)" >/dev/tty1 echo >/dev/tty1 sleep 10 } # falling back to vesa, reboot needed to # re-autodetect proper driver from now on [ "$failcount" -gt 2 ] && { x11setupdrv -s vesa xinit /opt/bin/kiosk.xinit } [ "$failcount" -gt 3 ] && { chvt 1 echo >/dev/tty1 echo "Graphics subsystem seems broken" >/dev/tty1 echo "Call Technical Support" >/dev/tty1 echo >/dev/tty1 sleep 60 exit 1 } done