forked from nsg-ethz/p4-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root-bootstrap.sh
123 lines (107 loc) · 2.52 KB
/
root-bootstrap.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
# Print commands and exit on errors
set -xe
#Install Generic Dependencies and Programs
apt-get update
KERNEL=$(uname -r)
DEBIAN_FRONTEND=noninteractive sudo apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
sudo apt-get install -y --no-install-recommends \
autoconf \
automake \
bison \
build-essential \
ca-certificates \
cmake \
cpp \
curl \
emacs nano\
flex \
git \
git-review \
libboost-dev \
libboost-filesystem-dev \
libboost-iostreams1.58-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-thread-dev \
libc6-dev \
libevent-dev \
libffi-dev \
libfl-dev \
libgc-dev \
libgc1c2 \
libgflags-dev \
libgmp-dev \
libgmp10 \
libgmpxx4ldbl \
libjudy-dev \
libpcap-dev \
libreadline6 \
libreadline6-dev \
libssl-dev \
libtool \
linux-headers-$KERNEL\
lubuntu-desktop \
make \
mktemp \
pkg-config \
python \
python-dev \
python-ipaddr \
python-setuptools \
tcpdump \
zip unzip \
vim \
wget \
xcscope-el \
xterm \
htop \
arping \
gawk \
iptables \
ipython \
libprotobuf-c-dev \
g++ \
bash-completion \
traceroute
#Install pip from source
apt-get purge python-pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
#python libraries
pip install ipaddress
#add swap memory
bash /vagrant/bin/add_swap_memory.sh
# Disable passwordless ssh
bash /vagrant/bin/ssh_ask_password.sh
#create user p4
useradd -m -d /home/p4 -s /bin/bash p4
echo "p4:p4" | chpasswd
echo "p4 ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99_p4
chmod 440 /etc/sudoers.d/99_p4
usermod -aG vboxsf p4
update-locale LC_ALL="en_US.UTF-8"
#set wallpaper
cd /usr/share/lubuntu/wallpapers/
cp /home/vagrant/nsg-logo.png .
rm lubuntu-default-wallpaper.png
ln -s nsg-logo.png lubuntu-default-wallpaper.png
rm /home/vagrant/nsg-logo.png
cd /home/vagrant
sed -i s@#background=@background=/usr/share/lubuntu/wallpapers/1604-lubuntu-default-wallpaper.png@ /etc/lightdm/lightdm-gtk-greeter.conf
# Disable screensaver
apt-get -y remove light-locker
# Automatically log into the P4 user
cat << EOF | tee -a /etc/lightdm/lightdm.conf.d/10-lightdm.conf
[SeatDefaults]
autologin-user=p4
autologin-user-timeout=0
user-session=Lubuntu
EOF
su p4 <<'EOF'
cd /home/p4
bash /vagrant/bin/user-bootstrap.sh
EOF
# Change Vagrant password. Otherwise if deployed in the wild it can be a vulnerability
# Alternative would be to make vagrant and root users only sshable with a key
echo "vagrant:gv82NEudNnp$w87[" | sudo chpasswd