1252995Sdteske#!/bin/sh
2252995Sdteske#-
3252995Sdteske# Copyright (c) 2012 Ron McDowell
4263791Sdteske# Copyright (c) 2012-2014 Devin Teske
5252995Sdteske# All rights reserved.
6252995Sdteske#
7252995Sdteske# Redistribution and use in source and binary forms, with or without
8252995Sdteske# modification, are permitted provided that the following conditions
9252995Sdteske# are met:
10252995Sdteske# 1. Redistributions of source code must retain the above copyright
11252995Sdteske#    notice, this list of conditions and the following disclaimer.
12252995Sdteske# 2. Redistributions in binary form must reproduce the above copyright
13252995Sdteske#    notice, this list of conditions and the following disclaimer in the
14252995Sdteske#    documentation and/or other materials provided with the distribution.
15252995Sdteske#
16252995Sdteske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17252995Sdteske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18252995Sdteske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19252995Sdteske# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20252995Sdteske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21252995Sdteske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22252995Sdteske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23252995Sdteske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24252995Sdteske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25252995Sdteske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26252995Sdteske# SUCH DAMAGE.
27252995Sdteske#
28252995Sdteske# $FreeBSD$
29252995Sdteske#
30252995Sdteske############################################################ INCLUDES
31252995Sdteske
32252995SdteskeBSDCFG_SHARE="/usr/share/bsdconfig"
33252995Sdteske. $BSDCFG_SHARE/common.subr || exit 1
34252995Sdteskef_dprintf "%s: loading includes..." "$0"
35252995Sdteskef_include $BSDCFG_SHARE/dialog.subr
36252995Sdteskef_include $BSDCFG_SHARE/mustberoot.subr
37263791Sdteskef_include $BSDCFG_SHARE/usermgmt/user.subr
38252995Sdteskef_include $BSDCFG_SHARE/usermgmt/user_input.subr
39252995Sdteske
40252995SdteskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
41252995Sdteskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
42252995Sdteske
43263791Sdteskef_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
44263791Sdteske	pgm="${ipgm:-$pgm}"
45252995Sdteske
46252995Sdteske############################################################ MAIN
47252995Sdteske
48252995Sdteske# Incorporate rc-file if it exists
49252995Sdteske[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
50252995Sdteske
51252995Sdteske#
52252995Sdteske# Process command-line arguments
53252995Sdteske#
54252995Sdteskewhile getopts h$GETOPTS_STDARGS flag; do
55252995Sdteske	case "$flag" in
56252995Sdteske	h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
57252995Sdteske	esac
58252995Sdteskedone
59252995Sdteskeshift $(( $OPTIND - 1 ))
60252995Sdteske
61252995Sdteske#
62252995Sdteske# Initialize
63252995Sdteske#
64252995Sdteskef_dialog_title "$msg_edit_view $msg_login"
65252995Sdteskef_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
66252995Sdteskef_mustberoot_init
67252995Sdteske
68252995Sdteske#
69263791Sdteske# If given a user name, operate on it and exit
70252995Sdteske#
71263791Sdteskeif [ "$1" ]; then
72263791Sdteske	f_user_edit "$1"
73263791Sdteske	exit $SUCCESS
74263791Sdteskefi
75263791Sdteske
76263791Sdteske#
77263791Sdteske# Present a list of users and loop until user Exits, Cancels or presses ESC
78263791Sdteske#
79263791Sdteskedefaultitem=
80252995Sdteskewhile :; do
81252995Sdteske	f_dialog_menu_user_list "$defaultitem"
82252995Sdteske	retval=$?
83252995Sdteske	f_dialog_menutag_fetch mtag
84252995Sdteske	f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
85252995Sdteske	defaultitem="$mtag"
86252995Sdteske
87263791Sdteske	[ $retval -eq $DIALOG_OK ] || f_die
88252995Sdteske
89252995Sdteske	[ "$mtag" = "X $msg_exit" ] && break
90252995Sdteske
91252995Sdteske	# Anything else is a userid
92252995Sdteske
93263791Sdteske	f_user_edit "$mtag"
94252995Sdteskedone
95252995Sdteske
96252995Sdteskeexit $SUCCESS
97252995Sdteske
98252995Sdteske################################################################################
99252995Sdteske# END
100252995Sdteske################################################################################
101