-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgua
More file actions
executable file
·38 lines (34 loc) · 1.44 KB
/
gua
File metadata and controls
executable file
·38 lines (34 loc) · 1.44 KB
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
# GUA - Guided User Add - Help in setting up users on a new system.
#
# NOTE: It is best to have ALL intended software installed before
# running this script. This script will skip right over any groups not
# found in /etc/group.
read -p "Enter name of user: " NEWUSER
CREATEHOME=
while [ ! `echo $CREATEHOME | grep [YNyn] >> /dev/null && echo $?` ]; do
echo -ne "\r \r"
read -p "Create home directory? [y/n] " -n1 CREATEHOME
done
echo ""
[[ $CREATEHOME == y || $CREATEHOME == Y ]] && HOMEOPTION=-m || HOMEOPTION=-M
echo -ne "\r"
read -p "Enter user id for $NEWUSER: " USERID
USERGROUPS[0]=junk
for GROUP in audio adbusers camera cdemu disk floppy games kvm locate lp network networkmanager optical power ssh storage sys thinkpad uucp vboxusers vmware video wheel wireshark; do
if [ `cat /etc/group | grep $GROUP >> /dev/null && echo $?` ]; then
ANSWER=
while [ ! `echo $ANSWER | grep [YNyn] >> /dev/null && echo $?` ]; do
echo -ne "\r \r"
read -p "Add user to group ${GROUP}? [y/n] " -n1 ANSWER
done
echo
[[ $ANSWER == y || $ANSWER == Y ]] && USERGROUPS=("${USERGROUPS[@]}" "$GROUP")
else
echo "Group $GROUP is not defined in /etc/group."
fi
done
if [[ -n ${USERGROUPS[@]} ]]; then
useradd $HOMEOPTION -g users $NEWUSER -u $USERID
else
useradd $HOMEOPTION -g users -G `echo ${USERGROUPS[@]:1:${#USERGROUPS[@]}} | tr ' ' ','` $NEWUSER -u $USERID
fi