#!/bin/sh
#@(#)HP Netstation Admin Scripts
#
# xdmmenu	scologin Administration Menu
#

if [ $OS = "sun4" -o $OS = "sun5" -a -f $OPENWINHOME/lib/Xinitrc ]
then
  XSESSION=".xsession or .xinitrc"
else
  XSESSION=".xsession"
fi

if [ $OS = "sco" ]
then
  while [ 0 ] 
  do
cat <<EOF

	_________________________________________________
		HP NETSTATION ADMINISTRATIVE TASKS
		    scologin ADMINISTRATION MENU

	1) Check current status of scologin

	2) enable scologin  (start it now, start it after reboots as well)

	3) disable scologin (stop it now, and don't start it after reboots)

	4) start scologin   (start it now)

	5) stop scologin    (stop it now)

	6) Create $XSESSION script in user's home directory 

		?) Help		p) previous menu

EOF
  	$ECHO "Please enter selection (default=1): $NL"
	read SEL 
	case $SEL in
	   1|"")
		$SCOLOGINQUERY 
		;; 
	      2)
		echo ""
		echo "WARNING: if you have an \":0\" line in /usr/lib/X11/scologin/Xservers you may"
		echo "have to comment it out before proceeding."
		echo "If you do not do this, your console may be blocked by scologin."
  	        $ECHO "Please type y to continue, anything else to quit: $NL"
	        read SEL 
		echo ""
		case $SEL in
		y|yes|Y|YES)
			:
			;;
                          *)
		        exit 100
			;;
		esac

		$SCOLOGINENABLE 
		;; 
	      3)
		$SCOLOGINDISABLE 
		;; 
	      4)
		echo ""
		echo "WARNING: if you have an \":0\" line in /usr/lib/X11/scologin/Xservers you may"
		echo "have to comment it out before proceeding."
		echo "If you do not do this, your console may be blocked by scologin."
  	        $ECHO "Please type y to continue, anything else to quit: $NL"
	        read SEL 
		echo ""
		case $SEL in
		y|yes|Y|YES)
			:
			;;
                          *)
		        exit 100
			;;
		esac
		$SCOLOGINSTART 
		;;
	      5)
		$SCOLOGINSTOP 
		;; 
              6)
		makexsession 
		;; 
	  p*|P*)
		exit 100
		;; 
	     \?)
		cat <<EOF

6) Create xsession script in user's home directory
	Will create a customizable .xsession wth default 
	X clients in user's home directory. 

No help available for other selections.
(See man page for scologin, eg at the unix prompt type "man scologin") 

EOF
		;;
	      *)
		echo ""
		echo "Invalid selection"
		continue
		;; 
	esac

	$ECHO "Please type <Enter> to continue $NL"
	read SEL
  done
fi

######################end of SCO######################################


#
# xdmmenu	XDM Administration Menu
#


while [ 0 ] 
do
cat <<EOF

	_________________________________________________
		HP NETSTATION ADMINISTRATIVE TASKS
		    XDM ADMINISTRATION MENU

	1) Check operation of xdm

	2) Start xdm

	3) Create $XSESSION script in user's home directory 

	4) Stop xdm

	5) Enable/disable xdm password aging

	6) Enable/disable xdm root login

	7) Trim xdm logfile

		?) Help		p) previous menu

EOF
  	$ECHO "Please enter selection (default=1): $NL"
	read SEL 
	case $SEL in
	   1|"")
		ckxdm 
		;; 
	      2)
		startxdm 
		;; 
	      3)
		#
		# force to ask question about .xsession / .xinitrc for sun
		# by removing XSESSIONCHOICE
		#
		rm $ADMINDIR/XSESSIONCHOICE > /dev/null 2>&1
		makexsession 
		;; 
	      4)
		killxdm 
		;; 
	      5)
		pwaging
		;;
	      6)
		lmrootlogin 
		;; 
	      7)
		trimlog 
		;; 
	  p*|P*)
		exit 100
		;; 
	     \?)
		cat <<EOF

Selecting:
1) Check operation of xdm
	Will check if xdm is currently running.
2) Start xdm
	Will start up xdm if it is not currently running.
3) Create xsession script in user's home directory
	Will create a customizable .xsession wth default 
	X clients in user's home directory. 
4) Stop xdm
	Will stop all currently running xdm sessions.
5) Enable/disable xdm password aging
	Allows you add/remove the password aging option.
6) Enable/disable xdm root login
	Allows you to prohibit root logins through xdm.
7) Trim xdm logfile
	Allows you to trim old entries in the xdm error log.

EOF
		;;
	      *)
		echo ""
		echo "Invalid selection"
		continue
		;; 
	esac

	RETCODE=$?
	if [ $RETCODE -ne 100 ]
	then
		$ECHO "Please type <Enter> to continue $NL"
		read SEL
	fi
done
