-
Notifications
You must be signed in to change notification settings - Fork 2
/
post_setup.sh
executable file
·54 lines (45 loc) · 1.54 KB
/
post_setup.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
#!/bin/bash
chmod -R g+w /local/onvm/*
source /local/onvm/openNetVM/scripts/setup_cloudlab.sh
echo "setting DPDK/ONVM"
yes n | /local/onvm/openNetVM/scripts/setup_environment.sh
echo "Setting up geniuser account"
cat mware.pub >> ~geniuser/.ssh/authorized_keys
sudo usermod -s /bin/bash geniuser
echo "source /local/onvm/openNetVM/scripts/setup_cloudlab.sh" >> ~geniuser/.bashrc
echo "Setting up tutorial account"
if [ $(id -u) -eq 0 ]; then
username="tutorial"
pass="paUoMiT7vjLqo" # this is the encrypted password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
else
# pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass -G root $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
fi
mkdir ~tutorial/.ssh
cat mware.pub >> ~tutorial/.ssh/authorized_keys
chmod 600 ~tutorial/.ssh/authorized_keys
chown -R tutorial ~tutorial
sudo usermod -s /bin/bash tutorial
grep "setup_cloudlab.sh" ~tutorial/.bashrc >/dev/null
if [ $? -eq 0 ]; then
echo "tutorial bashrc already has setup_cloudlab scripts"
else
echo "source /local/onvm/openNetVM/scripts/setup_cloudlab.sh; unset ONVM_PATH" >> ~tutorial/.bashrc
fi
echo "Setup ONVM environment for all users"
for f in /users/*/.bashrc
do
grep "setup_cloudlab.sh" $f >/dev/null
if [ $? -eq 0 ]; then
echo "$f already has ONVM setup"
else
echo "source /local/onvm/openNetVM/scripts/setup_cloudlab.sh; unset ONVM_PATH" >> $f
fi
done