-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinit.sh
More file actions
128 lines (106 loc) · 3.97 KB
/
Copy pathinit.sh
File metadata and controls
128 lines (106 loc) · 3.97 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
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
124
125
126
127
128
#!/bin/bash
#
# provision vmss virtual machine
#
set -ex
sudo sed -i 's/1/0/' /etc/apt/apt.conf.d/20auto-upgrades || true
source /etc/os-release
function install_packages(){
# install docker
sudo apt-get -o DPkg::Lock::Timeout=600 update
sudo apt-get -o DPkg::Lock::Timeout=600 install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common || return
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get -o DPkg::Lock::Timeout=600 update
sudo apt-get -o DPkg::Lock::Timeout=600 install -y docker-ce docker-ce-cli containerd.io || return
# install qemu for multi-arch docker
#sudo apt-get install -y qemu binfmt-support qemu-user-static
# install utilities for image build
sudo apt-get -o DPkg::Lock::Timeout=600 install -y make || return
sudo apt-get -o DPkg::Lock::Timeout=600 install -y python3-pip || return
pip3 install --force-reinstall --upgrade jinja2==2.10 || return
pip3 install j2cli==0.3.10 markupsafe==2.0.1 || return
# for team services agent
sudo apt-get -o DPkg::Lock::Timeout=600 install -y python-is-python2
# install python2 libvirt 5.10.0
sudo apt-get -o DPkg::Lock::Timeout=600 install -y python2-dev python-pkg-resources libvirt-dev pkg-config || return
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
pip2 install libvirt-python==5.10.0
pip2 install docker==4.4.1
# install packages for vs test
pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker==4.4.1 redis==3.3.4
sudo apt-get -o DPkg::Lock::Timeout=600 install -y libhiredis0.14 || return
# install packages for kvm test
sudo apt-get -o DPkg::Lock::Timeout=600 install -y libvirt-clients \
qemu \
openvswitch-switch \
net-tools \
bridge-utils \
util-linux \
iproute2 \
vlan \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
python3-libvirt \
libzmq3-dev \
libzmq5 \
libboost-serialization1.71.0 \
uuid-dev || return
}
for ((i=0;i<10;i++));do
install_packages && break
sleep 30
done
# install br_netfilter kernel module
modprobe br_netfilter
# set sysctl bridge parameters for testbed
sysctl -w net.bridge.bridge-nf-call-arptables=0
sysctl -w net.bridge.bridge-nf-call-ip6tables=0
sysctl -w net.bridge.bridge-nf-call-iptables=0
# set sysctl RCVBUF default parameter for testbed
sysctl -w net.core.rmem_default=509430500
# enable traffic forward
/usr/sbin/iptables -A FORWARD -j ACCEPT
# enable nat
iptables -t nat -A POSTROUTING -s 10.250.0.0/24 -o eth0 -j MASQUERADE
# echo add tmp user so that AzDevOps user id will be 1002.
# this is needed as sonic-mgmt container has an user id 1001 already
useradd -M sonictmp
# echo creating tmp AzDevOps account
tmpuser=AzDevOps
useradd -m $tmpuser
usermod -a -G docker $tmpuser
usermod -a -G adm $tmpuser
usermod -a -G sudo $tmpuser
echo "$tmpuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/100-$tmpuser
chmod 440 /etc/sudoers.d/100-$tmpuser
sudo pip3 install docker==6.1.0 requests==2.31.0
sudo apt-get -o DPkg::Lock::Timeout=600 install libyang0.16 libboost1.71-dev libboost-dev
# create two partition on the 1T data disk
# first partition for azure pipeline agent
# second partition for data
# find data disk, assume it is 1T
datadisk=$(lsblk -d | grep -E '[[:space:]]1T[[:space:]]' | awk '{print $1}')
sgdisk -n 0:0:500G -t 0:8300 -c 0:agent /dev/$datadisk
sgdisk -n 0:0:0 -t 0:8300 -c 0:data /dev/$datadisk
mkfs.ext4 /dev/${datadisk}1
mkfs.ext4 /dev/${datadisk}2
mkdir /agent
mount /dev/${datadisk}1 /agent
mkdir /data
mount /dev/${datadisk}2 /data
# clone sonic-mgmt repo
pushd /data
git clone https://github.com/Azure/sonic-mgmt
chown -R $tmpuser.$tmpuser /data/sonic-mgmt
popd