#!/bin/bash
#
# set_login_type
#
# simply sets the login type to GRAPHICAL or TEXT-BASED
# makes sure user requesting the change is root
# then simply changes /etc/inittab initdefault id value to 3 or 4, accordingly
#

c=`grep id:3:initdefault: /etc/inittab`
if [ ! "$c" == "" ]; then
	DIALOG=Xdialog
	$DIALOG --title "Hey --" --msgbox "\nLogin is already set to TEXT mode.\n" 0 0
	exit
else
	cp /etc/inittab /etc/inittab.bak
	sed -e 's/id:4:initdefault:/id:3:initdefault:/' /etc/inittab > /etc/inittab.$$
	mv /etc/inittab.$$ /etc/inittab
	DIALOG=Xdialog
	$DIALOG --title "Success" --msgbox "\nLogin has been set to TEXT mode.\nReboot for change to take effect.\n\nIf your screen is messed up,\nlogon in text mode and run\n\"safex\"" 0 0
fi
exit

