-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_profile
65 lines (52 loc) · 1.09 KB
/
.bash_profile
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
# .bash_profile
function create_environment()
{
# Setup the environment by copying the skeleton directory
# to a directory with the name of the user
echo "
-------
Warning
-------
You all work using the ${USER} login, but you have
your own home directory. Please, be careful with
other user's files.
"
cp -r ${HOME}/skel ${HOME}/${user}
cp -r ${HOME}/.ssh ${HOME}/${user}
}
function user_login()
{
# Ask the user's name and change the $HOME to his directory
trap "exit 0" SIGINT
echo "Who are you?"
echo "------------"
source ${HOME}/users
select user in "${ALL_USERS[@]}"
do
if [[ ! -z ${user} ]]
then
read -p "Confirm ${user} ? [y/N] " result
if [[ ${result} == [Yy] ]]
then
break
fi
fi
done
user=( ${user} )
if [[ ! -d ${user} ]]
then
# 1st login
create_environment ${user}
fi
export HOME=${HOME}/${user}
echo "
Your HOME directory is ${HOME}"
cp -f .Xauthority ${HOME}
cd ${HOME}
exec bash
exit 0
}
# If shell is interactive, ask the user his name
case "$-" in
*i*) user_login ;;
esac