-
Notifications
You must be signed in to change notification settings - Fork 8
/
start-ovs-rpm.sh
executable file
·246 lines (225 loc) · 4.83 KB
/
start-ovs-rpm.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/bin/bash
OPTIND=1
nodownload=0
verbose=0
while getopts "h?v?n" opt; do
case "$opt" in
h|\?)
echo "Please read the script ;)"
exit 0
;;
v) verbose=1
;;
n) nodownload=1
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
LOG_FILE=ovs-$$.out
ERR_FILE=ovs-$$.err
# Close STDOUT file descriptor and Copy it to 3
exec 3<&1
exec 1<&-
# Close STDERR FD and Copy it to 4
exec 4<&2
exec 2<&-
# Open STDOUT as $LOG_FILE file for read and write.
exec 1>$LOG_FILE
# Redirect STDERR to STDOUT
exec 2>$ERR_FILE
C="0" # count
spin() {
case "$(($C % 4))" in
0) char="/"
;;
1) char="-"
;;
2) char="\\"
;;
3) char="|"
;;
esac
echo -ne $char "\r" >&3
C=$[$C+1]
}
endspin() {
printf "\r%s\nPlease check logfile: $LOG_FILE\n" "$@" >&3
}
echos () {
printf "\r%s\n" "$@" >&3
}
if [ "$nodownload" == "0" ]; then
echos "Starting to install Openvswitch with support for NSH"
git clone https://github.com/priteshk/ovs.git
if [ $? -gt 0 ]; then
endspin "ERROR:Cloning git repo failed."
exit 1
fi
fi
spin
cd ovs
spin
git stash
spin
git checkout nsh-v8
spin
git branch -v >&3
spin
git clean -x -d -f
spin
echos "Removing old ovs configuration."
spin
sudo systemctl stop openvswitch
spin
sudo kill `cd /var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
spin
sudo rm -rf /var/run/openvswitch
spin
sudo mkdir -p /var/run/openvswitch
spin
sudo rm -rf /etc/openvswitch
spin
sudo mkdir -p /etc/openvswitch
spin
sudo rm -rf /var/run/openvswitch
spin
sudo mkdir -p /var/run/openvswitch
spin
sudo rm -rf /var/log/openvswitch
spin
sudo mkdir -p /var/log/openvswitch
spin
sudo rmmod openvswitch
spin
sudo rmmod gre
spin
sudo rmmod vxlan
spin
sudo rmmod libcrc32c
spin
sudo rmmod openvswitch
spin
sudo yum remove -y openvswitch
spin
./boot.sh
spin
./configure --with-linux=/lib/modules/`uname -r`/build
spin
sudo make uninstall
spin
git clean -x -d -f
spin
#sudo apt-get install -y build-essential
sudo yum groupinstall -y "Development Tools" "Development Libraries"
spin
sudo yum groupinstall -y "Additional Development"
spin
sudo yum install -y fakeroot
spin
#sudo apt-get install -y debhelper
spin
sudo yum install -y autoconf
spin
sudo yum install -y automake
spin
sudo yum install -y openssl-devel
spin
sudo yum install -y bzip2
spin
sudo yum install -y openssl
spin
sudo yum install -y graphviz
spin
sudo yum install -y '*python*' -python3-queuelib -python-django-federated-login -gcc-python3-plugin -python-qpid_messaging -gcc-python2-plugin -gcc-python3-debug-plugin -python-django* -django* -gcc-python2-debug-plugin -python3-django15-1.5.8-1 python-django-bash-completion* -python-django15*
spin
sudo yum install -y procps
spin
sudo yum install -y python-qt4
spin
sudo yum install -y python-zope-interface
spin
sudo yum install -y python-twisted-conch
spin
sudo yum install -y libtool
spin
sudo yum install -y rpm-build
spin
./boot.sh
spin
./configure
spin
make dist
spin
cp openvswitch.*.tar.gz ~/
spin
echos "openvswitch built...moving to ${HOME}/rpmbuild/SOURCES"
spin
if [ ! -d ~/rpmbuild/SOURCES ]; then
echo "creating rpmbuild dir..."
mkdir -p ~/rpmbuild/SOURCES
fi
spin
mv -f openvswitch-*.tar.gz ~/rpmbuild/SOURCES/
spin
pushd ~/rpmbuild/SOURCES/
spin
tar -xzf openvswitch*.tar.gz
spin
ls
cd openvswitch-*
if cat /etc/*release* | grep ID= | grep -i Fedora; then
os_type=fedora
elif cat /etc/*release* | grep ID= | grep -Ei 'CentOS|rhel'; then
os_type=rhel6
else
echo 'ERROR: OS Type is not Fedora or RHEL/CentOS..exiting!'
exit 1
fi
spin
kernel_version=$(uname -a | awk '{print $3}')
echo "OS Type $os_type detected with kernel version $kernel_version"
kernel_major=$(echo $kernel_version | cut -d . -f 1 )
spin
if [ $kernel_major -gt 3 ]; then
echo "Will not build kernel module as kernel is too new"
build_kernel=false
else
echo "Building kernel module..."
if rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --without check rhel/openvswitch-kmod-${os_type}.spec; then
echo " Kernel RPM built!"
build_kernel=true
else
echo "Unable to build kernel RPM..will try to build userspace RPM"
build_kernel=false
fi
fi
spin
echo "Building userspace module"
if rpmbuild -bb -D "kversion $kernel_version" -D "kflavors default" --without check rhel/openvswitch.spec; then
echo "RPM built successfully!!"
build_user=true
else
echo "Unable to build user RPM. Check Logs. Exiting..."
exit 1
fi
spin
popd
pushd ~/rpmbuild/RPMS/x86_64/
echo "Installing RPM..."
if sudo rpm -i openvswitch-*.rpm; then
echo "Able to install openvswitch!"
else
endspin "Unable to install openvswitch! Check ~/rpmbuild/RPMS/x86_64/"
exit 1
fi
popd
spin
sudo systemctl restart openvswitch
spin
sudo systemctl enable openvswitch
sudo lsmod | grep -i open
spin
sudo ovs-vsctl show >&3
spin
echo "Install Complete!"