#!/bin/sh
#
# sysopmenu.sh - menu for sysops
#
ISPUTIL="/var/lib/ISPutil"
BBSUTIL="/var/lib/BBSutil"
hostname=`hostname`
dnsdomainname=`dnsdomainname`
TITLE="$hostname.$dnsdomainname Sysop"
SYSOPEDITOR="/usr/bin/pico"
SUPER="/usr/bin/super"


# note not against left margin so not substituted at install time:
 EDITOR="$SYSOPEDITOR"
 VISUAL="$EDITOR"

if [ "$SHELL" = "/bin/bash" ]; then
	bashaccess=
else
	bashaccess=NO
fi

DONE=
while [ -z $DONE ]; do
	reset
	if [ -z $bashaccess ]; then
		dialog --title " $TITLE " \
		--menu   "MAIN MENU" 17 50 10 \
		"ADMIN"	 "User Administration" \
		"BACK"   "Back from menu" \
		"CHAT"	 "Online Chat" \
		"EDIT"	 "Text Editor" \
		"HELP"	 "Write for help" \
		"KITS"   "Kits for users" \
		"LOGIN"  "Change login password" \
		"ONLINE" "See who is online" \
		"PPP"	 "Change account to PPP" \
		"SLIP"	 "Change account to SLIP" \
		"X=EXIT" "Exit this menu" \
		"UNIX"	 "Unix shell (bash)" 2> /tmp/mch.tmp.$$
	else
		dialog --title " $TITLE " \
		--menu   "MAIN MENU" 18 50 11 \
		"ADMIN"	 "User Administration" \
		"BACK"   "Back from menu" \
		"CHAT"	 "Online Chat" \
		"EDIT"	 "Text Editor" \
		"HELP"	 "Write for help" \
		"KITS"   "Kits for users" \
		"LOGIN"  "Change login password" \
		"ONLINE" "See who is online" \
		"PPP"	 "Change account to PPP" \
		"SLIP"	 "Change account to SLIP" \
		"X=EXIT" "Exit this menu" 2> /tmp/mch.tmp.$$
	fi
	if [ $? = 1 -o $? = 255 ]; then
		/bin/rm -f /tmp/tmpmsg.$$ /tmp/mch.tmp.$$
		exit
	fi
	choice=`cat /tmp/mch.tmp.$$`
	/bin/rm -f /tmp/mch.tmp.$$

        if [ "$choice" = "ADMIN" ]; then
        $SUPER usradmin.sh
        fi
        if [ "$choice" = "BACK" ]; then
        exit
        fi
        if [ "$choice" = "CHAT" ]; then
        /usr/local/bin/vchat
        fi
        if [ "$choice" = "KITS" ]; then
        $ISPUTIL/util/kitsmenu.sh
        fi
        if [ "$choice" = "PPP" ]; then
        $SUPER ch2ppp.sh
        fi
        if [ "$choice" = "SLIP" ]; then
        $SUPER ch2slip.sh
        fi
        if [ "$choice" = "DISK" ]; then
        /usr/sbin/quota -v >/tmp/usradmin.tmp.$$
        dialog --title "Disk Quotas" \
        --textbox /tmp/usradmin.tmp.$$ 18 76
        /bin/rm -f /tmp/usradmin.tmp.$$
        fi
        if [ "$choice" = "EDIT" ]; then
        $VISUAL
        fi
        if [ "$choice" = "LOGIN" ]; then
        /usr/bin/passwd
        fi
	if [ "$choice" = "ONLINE" ]; then
	/usr/bin/finger @dialup1 > /tmp/usradmin.tmp.$$
        dialog --title "Users Online" \
        --textbox /tmp/usradmin.tmp.$$ 18 76
        /bin/rm -f /tmp/usradmin.tmp.$$
        fi
#        if [ "$choice" = "TIME" ]; then
#        $SUPER buytime.sh
#        fi
        if [ "$choice" = "X=EXIT" ]; then
        exit
        fi
        if [ "$choice" = "UNIX" ]; then
        	rm -f $HOME/.menu_lock
		exit
        fi
done
