/
health-check.install
executable file
·194 lines (167 loc) · 6.26 KB
/
health-check.install
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
#!/bin/bash
#
# Copyright (C) 2013-2014 eNovance SAS <licensing@enovance.com>
#
# Author: Frederic Lepied <frederic.lepied@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
src="$1"
DST="$2"
dir="$2_tmp"
IMG="$3"
vers="$4"
PYDIR=$(cd $(dirname $0)/../src; pwd)
PYSERVERDIR=$(cd $(dirname $0)/../server; pwd)
ORIG=$(cd $(dirname $0); pwd)
ROLE=health-check
# This is a stripped target as per rsync
export STRIPPED_TARGET=1
. ${ORIG}/common
if [ ! -d "$src" -o -z "$DST" -o -z "$IMG" -o -z "$vers" ]; then
echo "Usage: $0 <source dir> <dest dir> <initrd to generate> <version>" 1>&2
exit 1
fi
mkdir -p $dir
check_variables
set -x
set -e
rsync -aHX --delete-before --numeric-ids ${src}/ ${dir}/
common_setup
# netperf is in multiverse
if [ "$OS" = "Ubuntu" ]; then
repository=$(add_main_repository $DIST)
cat > ${dir}/etc/apt/sources.list.d/multiverse.list << EOF
deb $repository precise multiverse
deb $repository precise-updates multiverse
EOF
fi
PACKAGES="sdparm gzip sysbench mcelog smartmontools python-pip python-netaddr python-ipaddr gcc"
case "$DIST" in
$supported_centos_dists | $supported_redhat_dists)
add_epel_repository $DIST
PACKAGES="$PACKAGES numpy http://pkgs.repoforge.org/netperf/netperf-2.6.0-1.el6.rf.x86_64.rpm"
if [ "$CODENAME_MAJOR" = '6' ]; then
add_scn_feature $DIST python27
install_packages $dir "gcc"
do_chroot $dir scl enable python27 'easy_install netaddr pexpect psutil ipaddr'
remove_scn_repository
PACKAGES="$PACKAGES python-psutil http://pkgs.repoforge.org/fio/fio-2.1.7-1.el6.rf.x86_64.rpm http://pkgs.repoforge.org/lshw/lshw-2.17-1.el6.rf.x86_64.rpm"
else
install_packages $dir python-setuptools python-devel gcc gcc-c++ lshw redhat-rpm-config
do_chroot $dir easy_install netaddr pexpect psutil ipaddr
PACKAGES="$PACKAGES http://pkgs.repoforge.org/fio/fio-2.1.7-1.el7.rf.x86_64.rpm"
fi
;;
$supported_debian_dists | $supported_ubuntu_dists)
install_packages $dir "python-pip gcc g++ subversion python-dev"
do_chroot $dir pip install -U numpy
PACKAGES="$PACKAGES python-netaddr netperf python-psutil fio lshw libc6-dev"
;;
esac
update_repositories $dir
install_packages $dir "$PACKAGES"
do_chroot $dir pip install hardware
clear_packages_cache $dir
install_ib_if_needed $ORIG $dir
cp sources/timings.c ${dir}/root
do_chroot ${dir} gcc -Os /root/timings.c -o /usr/sbin/ddr-timings-$(uname -m)
rm ${dir}/root/timings.c
remove_packages ${dir} gcc libc6-dev
save_package_list $dir
#Starting here, we don't need the mount points anymore
clean_mount_points
rsync -au --delete-excluded --delete --exclude /boot/ \
--exclude 'initrd*' \
--exclude 'lib/modules/*/kernel/drivers/bluetooth' \
--exclude 'lib/modules/*/kernel/drivers/gpu/' \
--exclude 'lib/modules/*/kernel/drivers/isdn/' \
--exclude 'lib/modules/*/kernel/drivers/media' \
--exclude 'lib/modules/*/kernel/drivers/net/mac80211' \
--exclude 'lib/modules/*/kernel/drivers/net/wireless/' \
--exclude 'lib/modules/*/kernel/drivers/sound' \
--exclude 'lib/modules/*/kernel/drivers/uwb' \
--exclude 'lib/modules/*/kernel/drivers/video' \
--exclude 'lib/modules/*/kernel/net/netfilter' \
--exclude 'lib/modules/*/kernel/sound' \
--exclude 'ocfs2*.ko' \
--exclude '*.pyc' \
--exclude usr/lib/*/gconv/ \
--exclude usr/lib/locale \
--exclude usr/lib64/libgtk* \
--exclude usr/lib64/graphviz \
--exclude usr/share/anaconda \
--exclude usr/share/backgrounds \
--exclude usr/share/cracklib \
--exclude usr/share/cvs \
--exclude usr/share/doc \
--exclude usr/share/dracut \
--exclude usr/share/firstboot \
--exclude usr/share/fonts \
--exclude usr/share/gettext \
--exclude usr/share/groff \
--exclude usr/share/hwdata \
--exclude usr/share/i18n \
--exclude usr/share/ibmgtsim \
--exclude usr/share/icons \
--exclude usr/share/info \
--exclude usr/share/kde* \
--exclude usr/share/locale \
--exclude usr/share/man \
--exclude usr/share/misc \
--exclude usr/share/pixmaps \
--exclude usr/share/plymouth \
--exclude usr/share/swig \
--exclude usr/share/tcl* \
--exclude usr/share/tk* \
--exclude usr/share/wallpapers \
--exclude usr/share/X11 \
--exclude usr/share/yum* \
--exclude usr/share/zoneinfo \
--exclude usr/src \
--exclude var/cache \
--exclude var/lib/apt \
--exclude var/lib/dpkg \
--exclude var/lib/rpm \
--exclude var/lib/yum \
--exclude 'vmlinuz*' \
${dir}/ ${DST}
rm -rf ${dir}
cp -p init.common $DEPS ${PYDIR}/health*.py ${DST}/
cp -p init.health ${DST}/init
# RHEL6 do have an lshw that segfaults, so let's use a custom build.
# Yes, it's crap.
case "$DIST" in
$supported_centos_dists | $supported_redhat_dists)
if [ $CODENAME_MAJOR = 6 ]; then
if [ -x ${ORIG}/sources/lshw ]; then
cp -f ${ORIG}/sources/lshw ${DST}/usr/sbin
fi
fi
;;
esac
if [ -r ${DST}/etc/init.d/ssh ]; then
# If the ssh initscript features some upstart stuff, it needs to be disabled
sed -i "s/exec \/lib\/init\/upstart\-job ssh/echo 'No upstart check required'/g" ${DST}/etc/init.d/ssh
fi
sed -i "s/VERS=.*/VERS=${vers}/" ${DST}/init
GIT_REV=$(git rev-parse HEAD 2>/dev/null)
if [ ! -z "$GIT_REV" ]; then
sed -i "s/GIT_REV=.*/GIT_REV=\"${GIT_REV}\"/g" ${DST}/init.common
fi
echo "Creating initrd and compressing with $COMPRESS"
cd ${DST}; find . | cpio --quiet -R 0:0 -o -H newc | compress -9v > ../${IMG}
cd ..
md5sum ${IMG} > ${IMG}.md5
echo "### Build complete ###"
echo "### initrd is now available at ${DST}/../${IMG}"
echo "### Don't forget to use the initrd with its associated kernel : $(ls ${src}/boot/vmlinuz-*)"