1251843Sbapt#! /bin/sh
2251843Sbapt# $Id: inputmenu,v 1.15 2012/07/06 18:11:21 tom Exp $
3217309Snwhitehorn# 2002 - written by Tobias Rittweiler <tobrit@freebits.de>
4217309Snwhitehorn
5217309Snwhitehorn. ./setup-vars
6217309Snwhitehorn
7251843Sbaptuser="$USER"
8251843Sbaptuid=`id|sed -e 's/^uid=//' -e 's/(.*//'`
9251843Sbaptgid=`id|sed -e 's/^.*gid=//' -e 's/(.*//'`
10251843Sbapthome="$HOME"
11217309Snwhitehorn
12217309Snwhitehornwhile [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
13251843Sbapt	exec 3>&1
14251843Sbapt	value=`$DIALOG \
15251843Sbapt		--clear --ok-label "Create" \
16251843Sbapt		--backtitle "An Example for the use of --inputmenu:" "$@" \
17251843Sbapt		--inputmenu "Originally I designed --inputmenu for a \
18217309Snwhitehornconfiguration purpose. Here is a possible piece of a configuration program. \
19217309Snwhitehorn" 20 50 10 \
20217309Snwhitehorn"Username:" "$user" \
21217309Snwhitehorn"UID:"      "$uid" \
22217309Snwhitehorn"GID:"      "$gid" \
23217309Snwhitehorn"HOME:"     "$home" \
24251843Sbapt2>&1 1>&3 `
25251843Sbapt	returncode=$?
26251843Sbapt	exec 3>&-
27251843Sbapt	case $returncode in
28251843Sbapt	$DIALOG_CANCEL)
29251843Sbapt		"$DIALOG" \
30251843Sbapt			--clear --backtitle "An Example for the use of --inputmenu:" \
31251843Sbapt			--yesno "Really quit?" 10 30
32251843Sbapt		case $? in
33251843Sbapt		$DIALOG_OK) break;;
34251843Sbapt		$DIALOG_CANCEL) returncode=99;;
35251843Sbapt		esac
36251843Sbapt		;;
37251843Sbapt	$DIALOG_OK)
38251843Sbapt		"$DIALOG" \
39251843Sbapt			--clear --backtitle "An Example for the use of --inputmenu:"  \
40217309Snwhitehorn			--msgbox "useradd \n\
41217309Snwhitehorn				-d $home \n\
42217309Snwhitehorn				-u $uid \n\
43217309Snwhitehorn				-g $gid \n\
44217309Snwhitehorn				$user" 10 40
45251843Sbapt		;;
46251843Sbapt	$DIALOG_EXTRA)
47251843Sbapt		value=`echo "$value" | sed -e 's/^RENAMED //'`
48251843Sbapt		tag=`echo "$value" | sed -e 's/:.*//'`
49251843Sbapt		item=`echo "$value" | sed -e 's/^[^:]*:[ 	][ 	]*//'`
50217309Snwhitehorn
51251843Sbapt		case "$tag" in
52251843Sbapt		Username) user="$item" ;;
53251843Sbapt		UID)	  uid="$item"  ;;
54251843Sbapt		GID)	  gid="$item"  ;;
55251843Sbapt		HOME)	  home="$item" ;;
56251843Sbapt		esac
57251843Sbapt		;;
58217309Snwhitehorn
59251843Sbapt	$DIALOG_ESC)
60251843Sbapt		echo "ESC pressed."
61251843Sbapt		break
62251843Sbapt		;;
63217309Snwhitehorn
64251843Sbapt	esac
65217309Snwhitehorndone
66