Contents of /trunk/mage/usr/lib/mage/muserdel
Parent Directory | Revision Log
Revision 1273 -
(show annotations)
(download)
Wed Apr 27 09:45:07 2011 UTC (13 years, 5 months ago) by niro
File size: 1052 byte(s)
Wed Apr 27 09:45:07 2011 UTC (13 years, 5 months ago) by niro
File size: 1052 byte(s)
-support busybox out-of-the-box
1 | #!/bin/bash |
2 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/muserdel,v 1.4 2005-06-01 15:48:46 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/passwd." |
12 | echo " USAGE: $(basename $0 .sh) USER_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 | USER_TO_DEL="$1" |
27 | |
28 | # busybox support needed? |
29 | if need_busybox_support deluser |
30 | then |
31 | echo " Deleting user '${USER_TO_DEL}' ..." |
32 | deluser "${USER_TO_DEL}" |
33 | |
34 | # normal systems |
35 | else |
36 | #start nscd to cache passwd |
37 | $(which nscd) -i passwd |
38 | # get the info |
39 | my_user="$(getent passwd ${USER_TO_DEL})" |
40 | |
41 | if [ -z "${my_user}" ] |
42 | then |
43 | echo " User '${USER_TO_DEL}' already deleted ..." |
44 | else |
45 | echo " Deleting user '${USER_TO_DEL}' ..." |
46 | userdel "${USER_TO_DEL}" |
47 | fi |
48 | fi |