14c8945a0SNathan Whitehorn#! /bin/sh 2*a96ef450SBaptiste Daroussin# $Id: inputmenu2,v 1.12 2020/11/26 00:29:26 tom Exp $ 34c8945a0SNathan Whitehorn# 44c8945a0SNathan Whitehorn# "inputmenu1" with defaultitem, help-button. 54c8945a0SNathan Whitehorn 64c8945a0SNathan Whitehorn. ./setup-vars 74c8945a0SNathan Whitehorn 84c8945a0SNathan Whitehornbacktitle="An Example for the use of --inputmenu:" 94c8945a0SNathan Whitehorn 104c8945a0SNathan Whitehornids=`id|sed -e 's/([^)]*)//g'` 114c8945a0SNathan Whitehornuid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'` 124c8945a0SNathan Whitehorngid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'` 134c8945a0SNathan Whitehorn 144c8945a0SNathan Whitehornuser="$USER" 154c8945a0SNathan Whitehornhome="$HOME" 164c8945a0SNathan Whitehorn 174c8945a0SNathan Whitehornreturncode=0 184c8945a0SNathan Whitehorndefaultitem="Username:" 194c8945a0SNathan Whitehornwhile test $returncode != 1 && test $returncode != 250 204c8945a0SNathan Whitehorndo 214c8945a0SNathan Whitehornexec 3>&1 22*a96ef450SBaptiste Daroussinreturntext=`$DIALOG --clear --ok-label "Create" \ 234c8945a0SNathan Whitehorn --backtitle "$backtitle" \ 244c8945a0SNathan Whitehorn --help-button \ 254c8945a0SNathan Whitehorn --help-label "Script" \ 264c8945a0SNathan Whitehorn --default-item "$defaultitem" "$@" \ 274c8945a0SNathan Whitehorn --inputmenu "Originally I designed --inputmenu for a \ 284c8945a0SNathan Whitehornconfiguration purpose. Here is a possible piece of a configuration program." \ 294c8945a0SNathan Whitehorn20 60 10 \ 304c8945a0SNathan Whitehorn "Username:" "$user" \ 314c8945a0SNathan Whitehorn "UID:" "$uid" \ 324c8945a0SNathan Whitehorn "GID:" "$gid" \ 334c8945a0SNathan Whitehorn "HOME:" "$home" \ 344c8945a0SNathan Whitehorn2>&1 1>&3` 354c8945a0SNathan Whitehornreturncode=$? 364c8945a0SNathan Whitehornexec 3>&- 374c8945a0SNathan Whitehorn 384c8945a0SNathan Whitehorn case $returncode in 394c8945a0SNathan Whitehorn $DIALOG_HELP) 404c8945a0SNathan Whitehorn "$DIALOG" \ 414c8945a0SNathan Whitehorn --textbox "$0" 0 0 424c8945a0SNathan Whitehorn ;; 434c8945a0SNathan Whitehorn $DIALOG_CANCEL) 444c8945a0SNathan Whitehorn "$DIALOG" \ 454c8945a0SNathan Whitehorn --clear \ 464c8945a0SNathan Whitehorn --backtitle "$backtitle" \ 474c8945a0SNathan Whitehorn --yesno "Really quit?" 10 30 484c8945a0SNathan Whitehorn case $? in 494c8945a0SNathan Whitehorn $DIALOG_OK) 504c8945a0SNathan Whitehorn break 514c8945a0SNathan Whitehorn ;; 524c8945a0SNathan Whitehorn $DIALOG_CANCEL) 534c8945a0SNathan Whitehorn returncode=99 544c8945a0SNathan Whitehorn ;; 554c8945a0SNathan Whitehorn esac 564c8945a0SNathan Whitehorn ;; 574c8945a0SNathan Whitehorn $DIALOG_OK) 584c8945a0SNathan Whitehorn "$DIALOG" \ 594c8945a0SNathan Whitehorn --clear \ 604c8945a0SNathan Whitehorn --backtitle "$backtitle" \ 614c8945a0SNathan Whitehorn --msgbox "useradd \n\ 624c8945a0SNathan Whitehorn -d $home \n\ 634c8945a0SNathan Whitehorn -u $uid \n\ 644c8945a0SNathan Whitehorn -g $gid \n\ 654c8945a0SNathan Whitehorn $user" 10 40 664c8945a0SNathan Whitehorn ;; 674c8945a0SNathan Whitehorn $DIALOG_EXTRA) 68*a96ef450SBaptiste Daroussin tag=`echo "$returntext" |sed -e 's/^RENAMED //' -e 's/:.*/:/'` 69*a96ef450SBaptiste Daroussin item=`echo "$returntext" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'` 704c8945a0SNathan Whitehorn 714c8945a0SNathan Whitehorn case "$tag" in 724c8945a0SNathan Whitehorn Username:) 734c8945a0SNathan Whitehorn user="$item" 744c8945a0SNathan Whitehorn ;; 754c8945a0SNathan Whitehorn UID:) 764c8945a0SNathan Whitehorn uid="$item" 774c8945a0SNathan Whitehorn ;; 784c8945a0SNathan Whitehorn GID:) 794c8945a0SNathan Whitehorn gid="$item" 804c8945a0SNathan Whitehorn ;; 814c8945a0SNathan Whitehorn HOME:) 824c8945a0SNathan Whitehorn home="$item" 834c8945a0SNathan Whitehorn ;; 844c8945a0SNathan Whitehorn *) 854c8945a0SNathan Whitehorn tag= 864c8945a0SNathan Whitehorn ;; 874c8945a0SNathan Whitehorn esac 884c8945a0SNathan Whitehorn test -n "$tag" && defaultitem="$tag" 894c8945a0SNathan Whitehorn ;; 904c8945a0SNathan Whitehorn 91*a96ef450SBaptiste Daroussin *) 92*a96ef450SBaptiste Daroussin . ./report-button 934c8945a0SNathan Whitehorn break 944c8945a0SNathan Whitehorn ;; 954c8945a0SNathan Whitehorn 964c8945a0SNathan Whitehorn esac 974c8945a0SNathan Whitehorndone 98