Magellan Linux

Annotation of /branches/mage-next/src/helper/mgroupdel.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1273 - (hide annotations) (download)
Wed Apr 27 09:45:07 2011 UTC (13 years ago) by niro
Original Path: trunk/mage/usr/lib/mage/mgroupdel
File size: 1065 byte(s)
-support busybox out-of-the-box
1 niro 42 #!/bin/bash
2 niro 78 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mgroupdel,v 1.4 2005-06-01 15:48:40 niro Exp $
3 niro 42
4 niro 1273 # include all needed files
5     [ -f /etc/mage.rc.global ] && source /etc/mage.rc.global
6     [ -f ${MAGERC} ] && source ${MAGERC}
7     [ -f ${MLIBDIR}/mage4.functions.sh ] && source ${MLIBDIR}/mage4.functions.sh
8    
9 niro 42 print_usage()
10     {
11     echo "$(basename $0 .sh) deletes users from /etc/group."
12     echo " USAGE: $(basename $0 .sh) GROUP_NAME .."
13     echo
14     echo " Examples:"
15     echo " $(basename $0 .sh) sshd"
16     echo
17     }
18    
19     #exit if $1 is zero
20     if [ -z "$1" ]
21     then
22     print_usage
23     exit 1
24     fi
25    
26     GROUP_TO_DEL="$1"
27    
28 niro 1273 # busybox support needed?
29     if need_busybox_support delgroup
30     then
31     echo " Deleting user '${GROUP_TO_DEL}' ..."
32     delgroup "${GROUP_TO_DEL}"
33 niro 42
34 niro 1273 # normal systems
35 niro 42 else
36 niro 1273 #start nscd to cache /etc/group
37     $(which nscd) -i group
38     # get the info
39     my_user="$(getent group ${GROUP_TO_DEL})"
40    
41     if [ -z "${my_user}" ]
42     then
43     echo " User '${GROUP_TO_DEL}' already deleted ..."
44     else
45     echo " Deleting user '${GROUP_TO_DEL}' ..."
46     groupdel "${GROUP_TO_DEL}"
47     fi
48 niro 42 fi