Contents of /trunk/mage/usr/lib/mage/mgroupdel
Parent Directory | Revision Log
Revision 1273 -
(show annotations)
(download)
Wed Apr 27 09:45:07 2011 UTC (13 years, 2 months ago) by niro
File size: 1065 byte(s)
Wed Apr 27 09:45:07 2011 UTC (13 years, 2 months ago) by niro
File size: 1065 byte(s)
-support busybox out-of-the-box
1 | #!/bin/bash |
2 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mgroupdel,v 1.4 2005-06-01 15:48:40 niro Exp $ |
3 | |
4 | # 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 | 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 | # busybox support needed? |
29 | if need_busybox_support delgroup |
30 | then |
31 | echo " Deleting user '${GROUP_TO_DEL}' ..." |
32 | delgroup "${GROUP_TO_DEL}" |
33 | |
34 | # normal systems |
35 | else |
36 | #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 | fi |