#!/bin/sh

NAME=sunray
DESC="Sunray services"
case "$1" in
  start)
  	#[ ! -f /lib/modules/`uname -r`/misc/utadem.ko -a -d /usr/src/SUNWut/utadem ] && make -C /usr/src/SUNWut/utadem clean default install || /bin/true
	#[ ! -f /lib/modules/`uname -r`/misc/utio.ko -a -d /usr/src/SUNWut/utio ] && make -C /usr/src/SUNWut/utio clean default install || /bin/true
	#[ ! -f /lib/modules/`uname -r`/misc/utdisk.ko -a -d /usr/src/SUNWut/utdisk ] && make -C /usr/src/SUNWut/utdisk clean default install || /bin/true
	[ ! -d /etc/X11/xdm ]  && mkdir -p /etc/X11/xdm
	[ ! -f /bin/awk ]      && ln -s /usr/bin/awk /bin/awk
	[ ! -f /bin/basename ] && ln -s /usr/bin/basename /bin/basename
	echo "Starting $DESC: $NAME"
	/etc/init.d/utacleanup start
	/etc/init.d/utds start
	/etc/init.d/utsyscfg start
	[ -x /etc/init.d/utstorage ] && /etc/init.d/utstorage start
	/etc/init.d/utsvc start
	;;
  stop)
	echo "Stopping $DESC: $NAME "
	/etc/init.d/utsvc stop
	[ -x /etc/init.d/utstorage ] && /etc/init.d/utstorage stop
	/etc/init.d/utacleanup stop
	/etc/init.d/utds stop
	/etc/init.d/utsyscfg stop
	/usr/bin/pkill -9 Xnewt
	/usr/bin/pkill utaction
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop}" >&2
	exit 1
	;;
esac

exit 0
