#!/bin/bash
#### INFO
# Provides:             X and AUI
# Required-Start:       uarts, network, nextgenserver
# Required-Stop:
# Description:          Advanced User Interface Nautel Ltd transmitters.
####

#Author:        David Dumke
#Date:          18 June, 2010
#LastModified:  18 June, 2010
#Version:       1.0

NAME=startaui
DESC="Advanced User Interface Nautel Ltd"
AUI_X_PIDFILE="/var/run/aui.pid"

SCRIPTNAME=/etc/init.d/$NAME
do_start() {
        # I will simply execute everything necessary to get x running here.
        # When restart is called we will assume something crashed(AUI watchdog
        # was kicked and X will be killed and brought back up.
        su nautel -c 'sleep 5; /usr/bin/startx &'
}

do_stop() {
        killall Xorg
}

# Carry out specific functions when asked to by the system
case "$1" in
	start)
		echo "Removing persistent net rules file"
		rm -f /etc/udev/rules.d/70-persistent-net.rules
		echo "Starting X"
 		do_start
	;;
	stop)
 		echo "Stopping X"
 		do_stop
 	;;
	restart)
 		echo "Restarting X"
		do_stop
		do_start
	;;
	*)
		echo "Usage: /etc/init.d/startaui {start|stop}"
		exit 1
	;;
esac

:
