#!/bin/sh # # run X case "$1" in -k) touch /tmp/x_stop killall X exit $? ;; -r) killall X exit $? ;; -n) touch /tmp/x_stop norestart=1 ;; -*) echo "Usage $0 {-k | -r | -q}" echo " -k kill X" echo " -r restart X" echo " -n no restart if an error occur" exit 1 ;; esac if [ "$norestart" != "1" ]; then rm -f /tmp/x_stop fi # accept only one instance ps | grep runx | grep -v grep | grep -q -v $$ && exit while (true) do if [ -e /tmp/x_stop ]; then rm -f /tmp/x_stop break fi # schnelle wiederholte Neustarts verzögern if [ 0$starttime -gt $(( `date +%s` - 15 )) ]; then sleep 10 "#delaying x restart" fi starttime=`date +%s` startx >>/var/log/x 2>&1 echo -n "x exits at "; date done