-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd-web-person-user.sh
63 lines (49 loc) · 1.3 KB
/
add-web-person-user.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
#!/bin/bash
######################################################################
######################################################################
#####NOTES & SNIPPETS#####
######################################################################
######################################################################
#based upon:
#
# http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
usage(){
echo "Usage: $0"
echo ""
echo "One mandatory argument"
echo "One optional argument, TRUE||FALSE, space delimited"
echo ""
echo "USERNAME (bradchesney79)*"
echo ""
echo "SUDO USER (FALSE)✓"
echo ""
echo "* denotes a required argument"
echo "✓ denotes a default value"
exit 1
}
# invoke usage
# call usage() function if parameters not supplied
[[ $# -eq 0 ]] && usage
if [ -z "$1" ]
then usage
fi
if [ "$1" == "-h" ]
then usage
fi
if [ "$1" == "--help" ]
then usage
fi
adduser "$1"
if [ "$2" ]
then
if [ "$2" == TRUE ]
then
echo "Adding User to sudoers"
echo "$1 ALL=(ALL:ALL) ALL" | (EDITOR="tee -a" visudo)
fi
fi
cat /etc/group | tr '\n' ' '
echo ""
echo "How to give a user access to other groups:"
echo "usermod -a --groups <pre-existing-group>[,<pre-existing-group>...] username"
echo "example: usermod -a --groups xyzcom-web,default-web bradchesney79"