#!/bin/sh
#
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: target/archivista/rootfs/sbin/init.d/xcfgt2
# Copyright (C) 2004 - 2008 The T2 SDE Project
# Copyright (C) 1998 - 2004 ROCK Linux Project
# 
# More information can be found in the files COPYING and README.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- T2-COPYRIGHT-NOTE-END ---
#
# ROCK Linux: /etc/rc.d/init.d/xfs
#
# Desc: X Detect
# Runlevel: 80 rcX
#

title() {
	local x w="$( stty size 2>/dev/null </dev/tty | cut -d" " -f2  )"
	[ -z "$w" ] && w="$( stty size </dev/console | cut -d" " -f2  )"
	for (( x=1; x<w; x++ )) do echo -n .; done
	echo -e "\e[222G\e[3D v \r\e[36m$* \e[0m"
	error=0
}

status() {
	if [ $error -eq 0 ]
	then
		echo -e "\e[1A\e[222G\e[4D\e[32m :-)\e[0m"
	else
		echo -e "\e[1A\e[222G\e[4D\a\e[1;31m :-(\e[0m"
	fi
}

case "$1" in

    start)
	title "Starting xfs."
        /usr/X11/bin/xcfgt2
    	status
	;;

    stop)
    	status
	;;

    restart)
	$0 stop; $0 start
	;;

    *)
	echo "Usage: $0 { start | stop | restart }"
	exit 1 ;;

esac

exit 0

