-
Notifications
You must be signed in to change notification settings - Fork 48
/
setup.sh
executable file
·101 lines (83 loc) · 3.32 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
#install necessary packages
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mininet
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y iperf3
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-tk
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y traceroute
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y bridge-utils
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y iputils-ping
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-psutil
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-netifaces
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y default-jdk
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y dovecot-pop3d
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y postfix
pip3 install --upgrade pip
pip3 install cpunetlog
pip3 install matplotlib
pip3 install ipykernel
#delete all existing dovecot and postfix config files and replace them with the config fils from the repo
sudo rm -rf /etc/postfix
sudo cp -r /home/labrat/kn1lab/msConfig/postfix /etc
sudo rm -rf /etc/dovecot
sudo cp -r /home/labrat/kn1lab/msConfig/dovecot /etc
sudo rm -rf /etc/aliases
sudo cp -r /home/labrat/kn1lab/msConfig/aliases /etc
sudo rm -rf /etc/aliases.db
sudo cp -r /home/labrat/kn1lab/msConfig/aliases.db /etc
sudo rm -rf /etc/mailcap
sudo cp -r /home/labrat/kn1lab/msConfig/mailcap /etc
sudo rm -rf /etc/mailcap.order
sudo cp -r /home/labrat/kn1lab/msConfig/mailcap.order /etc
sudo rm -rf /etc/mailname
sudo cp -r /home/labrat/kn1lab/msConfig/mailname /etc
#After giving the new config files restart the services
sudo service dovecot restart
sudo service postfix restart
#generate a ssh key pair for versuch4
rm $HOME/.ssh/id_rsa*
ssh-keygen -N "" -f $HOME/.ssh/id_rsa
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
#setup the Hostnames in the bash for versuch4 and add the cpunetlog scripts to PATH
sudo tee -a ~/.bashrc << EOF
### custom additions
# change prompt for mininet hosts
if [ ! -z \${SSH_CONNECTION+x} ]; then
MyIP=\$(echo \$SSH_CONNECTION | awk '{print \$3}')
case \$MyIP in
"10.0.0.1")
MyHostName="c1"
;;
"10.0.0.2")
MyHostName="c2"
;;
"10.0.0.3")
MyHostName="sv1"
;;
*)
MyHostName="unknown"
;;
esac
PS1="\e[01;32m\u@\$MyHostName:\e[m\e[01;34m\w\a\e[m\$ "
PROMPT_COMMAND='echo -ne "\033]0;\$USER@\$MyHostName\007"'
alias cnl_plot.py="echo \"Can't plot from an ssh session\""
fi
PATH=\$PATH:\$HOME/cpunetlog
EOF
#Assign the necessary IP-addresses to the given hosts
sudo tee -a /etc/hosts << EOF
127.0.1.1 kn1-lab.net.fail
10.0.0.1 c1
10.0.0.2 c2
10.0.0.3 sv1
EOF
#When the vm is started, the owning rights for the files are wrong, so they can not be edited, unless the rights are changed
sudo chown -R labrat /home/labrat/kn1lab
#Change the congestion control algorithm for tcp from cubic to reno, to better see som congestion control mechanisms in versuch4
echo "net.ipv4.tcp_congestion_control = reno" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
#Automatically install the necessary Visual Studio Code extensions
code --install-extension vscjava.vscode-java-pack
code --install-extension ms-python.python
code --install-extension ms-toolsai.jupyter