Annotation of /branches/mage-next/src/helper/muserdel
Parent Directory | Revision Log
Revision 1273 -
(hide annotations)
(download)
Wed Apr 27 09:45:07 2011 UTC (13 years, 1 month ago) by niro
Original Path: trunk/mage/usr/lib/mage/muserdel
File size: 1052 byte(s)
Wed Apr 27 09:45:07 2011 UTC (13 years, 1 month ago) by niro
Original Path: trunk/mage/usr/lib/mage/muserdel
File size: 1052 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/muserdel,v 1.4 2005-06-01 15:48:46 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/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 | niro | 1273 | # busybox support needed? |
29 | if need_busybox_support deluser | ||
30 | then | ||
31 | echo " Deleting user '${USER_TO_DEL}' ..." | ||
32 | deluser "${USER_TO_DEL}" | ||
33 | niro | 42 | |
34 | niro | 1273 | # normal systems |
35 | niro | 42 | else |
36 | niro | 1273 | #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 | niro | 42 | fi |