groupdel revision 256181
1285612Sdelphij#!/bin/sh
2181834Sroberto#-
3285612Sdelphij# Copyright (c) 2012 Ron McDowell
4285612Sdelphij# Copyright (c) 2012-2013 Devin Teske
5285612Sdelphij# All rights reserved.
6285612Sdelphij#
7285612Sdelphij# Redistribution and use in source and binary forms, with or without
8285612Sdelphij# modification, are permitted provided that the following conditions
9285612Sdelphij# are met:
10285612Sdelphij# 1. Redistributions of source code must retain the above copyright
11285612Sdelphij#    notice, this list of conditions and the following disclaimer.
12285612Sdelphij# 2. Redistributions in binary form must reproduce the above copyright
13285612Sdelphij#    notice, this list of conditions and the following disclaimer in the
14285612Sdelphij#    documentation and/or other materials provided with the distribution.
15285612Sdelphij#
16285612Sdelphij# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17285612Sdelphij# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18285612Sdelphij# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19285612Sdelphij# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20285612Sdelphij# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21285612Sdelphij# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22285612Sdelphij# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23285612Sdelphij# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24285612Sdelphij# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25285612Sdelphij# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26285612Sdelphij# SUCH DAMAGE.
27285612Sdelphij#
28285612Sdelphij# $FreeBSD: head/usr.sbin/bsdconfig/usermgmt/groupdel 256181 2013-10-09 08:12:26Z dteske $
29285612Sdelphij#
30285612Sdelphij############################################################ INCLUDES
31181834Sroberto
32285612SdelphijBSDCFG_SHARE="/usr/share/bsdconfig"
33181834Sroberto. $BSDCFG_SHARE/common.subr || exit 1
34181834Srobertof_dprintf "%s: loading includes..." "$0"
35181834Srobertof_include $BSDCFG_SHARE/dialog.subr
36181834Srobertof_include $BSDCFG_SHARE/mustberoot.subr
37181834Srobertof_include $BSDCFG_SHARE/usermgmt/group_input.subr
38181834Sroberto
39285612SdelphijBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
40181834Srobertof_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
41181834Sroberto
42285612Sdelphijipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
43181834Sroberto[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
44181834Sroberto
45285612Sdelphij############################################################ MAIN
46285612Sdelphij
47285612Sdelphij# Incorporate rc-file if it exists
48285612Sdelphij[ -f "$HOME/.bsdconfigrc" ] && f_include "$HOME/.bsdconfigrc"
49285612Sdelphij
50285612Sdelphij#
51181834Sroberto# Process command-line arguments
52181834Sroberto#
53181834Srobertowhile getopts h$GETOPTS_STDARGS flag; do
54285612Sdelphij	case "$flag" in
55285612Sdelphij	h|\?) f_usage $BSDCFG_LIBE/$APP_DIR/USAGE "PROGRAM_NAME" "$pgm" ;;
56181834Sroberto	esac
57285612Sdelphijdone
58285612Sdelphijshift $(( $OPTIND - 1 ))
59181834Sroberto
60285612Sdelphij#
61181834Sroberto# Initialize
62285612Sdelphij#
63285612Sdelphijf_dialog_title "$msg_delete $msg_group"
64285612Sdelphijf_dialog_backtitle "${ipgm:+bsdconfig }$pgm"
65181834Srobertof_mustberoot_init
66285612Sdelphij
67285612Sdelphij#
68285612Sdelphij# Loop until the user Exits, Cancels or presses ESC
69285612Sdelphij#
70285612Sdelphijdefaultitem=""
71285612Sdelphijwhile :; do
72285612Sdelphij	f_dialog_menu_group_list "$defaultitem"
73285612Sdelphij	retval=$?
74285612Sdelphij	f_dialog_menutag_fetch mtag
75285612Sdelphij	f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
76285612Sdelphij	defaultitem="$mtag"
77285612Sdelphij
78285612Sdelphij	[ $retval -eq $DIALOG_OK ] || f_die
79285612Sdelphij
80285612Sdelphij	[ "$mtag" = "X $msg_exit" ] && break
81285612Sdelphij
82285612Sdelphij	# Anything else is a group name
83285612Sdelphij
84285612Sdelphij	$BSDCFG_LIBE/$APP_DIR/groupinput \
85285612Sdelphij		${USE_XDIALOG:+-X} mode="Delete" group="$mtag"
86285612Sdelphijdone
87285612Sdelphij
88285612Sdelphijexit $SUCCESS
89285612Sdelphij
90285612Sdelphij################################################################################
91285612Sdelphij# END
92285612Sdelphij################################################################################
93285612Sdelphij