-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathaddUser.sh
executable file
·71 lines (56 loc) · 1.03 KB
/
addUser.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#set -x
set -e
set -u
usage()
{
cat <<EOF >&2
${txtcyn}
Usage:
$0 options${txtrst}
${bldblu}Function${txtrst}:
This script is used to do ********************.
${txtbld}OPTIONS${txtrst}:
-u User name ${bldred}[NECESSARY]${txtrst}
-p Password ${bldred}[NECESSARY]${txtrst}
-g Group ${bldred}[Currently support ehbio, probation, intern]${txtrst}
EOF
}
user=
password=
group=
while getopts "hu:p:g:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
u)
user=$OPTARG
;;
p)
password=$OPTARG
;;
g)
group=$OPTARG
;;
?)
usage
exit 1
;;
esac
done
if [ -z $user ]; then
usage
exit 1
fi
cat <<END >/tmp/${user}.create
${user}:${password}::${group}::/MPATHC/home/${user}:/bin/bash
END
newusers </tmp/${user}.create
/bin/cp -u /MPATHC/home/.bashrc /MPATHC/home/${user}/.bashrc
chown ${user}:${group} /MPATHC/home/${user}/.bashrc
/bin/cp -u /MPATHC/home/.bash_profile /MPATHC/home/${user}/.bash_profile
chown ${user}:${group} /MPATHC/home/${user}/.bash_profile
chmod go-rwx /MPATHC/home/${user}