#!/bin/bash
#
# gdm-allow-login     This shell script enables users to login to gdm
#
# chkconfig:	5 99 1
# description: This shell script enables users to login from the display manager

# source function library
. /etc/rc.d/init.d/functions

[ -f /usr/bin/gdm-binary ] || exit 0
strstr "$(cat /proc/cmdline)" "early-login" || exit 0

# Determine whether firstboot will run
do_firstboot() {
  if grep -i reconfig /proc/cmdline >/dev/null || [ -f /etc/reconfigSys ]; then
    return 0;
  fi

  if [ -f /etc/sysconfig/firstboot ] && ! grep -q '^RUN_FIRSTBOOT=YES' /etc/sysconfig/firstboot; then
     return 1;
   fi
}

if do_firstboot; then 
  exit 0;
fi

RETVAL=0

start() {
	echo -n $"Allow users to login from display manager:"
	echo "ALLOW_LOGIN" > /var/gdm/.gdmfifo && success || failure
	RETVAL=$?
	echo
}

stop() {
	echo
}

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

exit $RETVAL
