opencontrail-builder/buildKern
2017-07-19 09:40:15 +02:00

206 lines
6.8 KiB
Bash

#!/bin/bash
#
# Gemaakt voor RuG-CIT 2017-05-27 Door: Rein van Weerden
# ======================================================================
# buildKern Copyright dVR H&S Sys. 2017
# ======================================================================
#
# build is used to check a flag file set by a webhook and if
# go and build a kernel in a virtualbox
#
# ____
# <. .\
# \..|
# \ |___(\--/)
# __/ ( . . )
# "'._. '-.O.'
# '-. \ "|\
# '.,,/'., dVR
#
if [[ -n ${DX} ]]
then
exec 1>>/tmp/${0##*/}.log 2>&1
set -${DX} # Are you going to debug? (DX is set to 'x' (set DX='x') or unset)
fi
#
cd ${HOME}/build
if [[ ! -f /tmp/flg.build ]]
then
exit
else
if [[ -f flg.building ]]
then
echo "Busy with a build. Try again later"
exit
else
sudo mv /tmp/flg.build flg.building
fi
fi
DATUM="$(/bin/date '+%a %d %b (%V) %Y %H:%M:%S %Z')"
EPOCH="$(/bin/date '+%s')"
VBOXMANAGE=$(which VBoxManage)
VBOXMANAGE=${VBOXMANAGE:-"/usr/local/bin/VBoxManage"}
if [[ ! -x "${VBOXMANAGE}" ]]
then
echo "Command 'VBoxManage' not found, bailing out"
exit 1
fi
CLONENAME=$(/usr/local/bin/uuidgen -t)
CLONENAME=${CLONENAME%%-*}
cat << EOF > .gitconfig
[user]
name = plReynaerde
email = plreynaerde@dvrhss.net
[push]
default = simple
[filter "media"]
clean = git media clean %f
smudge = git media smudge %f
required = true
[http]
sslVerify = false
EOF
REPONAME=$(cat flg.building |sed -n '2p')
BRANCHNAME=$(cat flg.building |sed -n '3p')
CONFIGFILE=$(cat flg.building |sed -n '4p')
# CONFIGFILE=$(echo ${CONFIGFILE} |sed -e 's/:2242//')
KERNELSET=${CONFIGFILE%/*}
KERNELSET=${KERNELSET}/Kernel.git
cat << EOF > getAndBuild
#!/bin/bash -x
#
# Gemaakt voor RuG-CIT 2017-05-27 Door: Rein van Weerden
# ======================================================================
# getAndBuild Copyright dVR H&S Sys. 2017
# ======================================================================
#
# getAndBuild is used to check a flag file set by a webhook and if
# go and build a kernel in a virtualbox
#
# ____
# <. .\
# \..|
# \ |___(\--/)
# __/ ( . . )
# "'._. '-.O.'
# '-. \ "|\
# '.,,/'., dVR
#
if [[ -n \${DX} ]]
then
exec 1>>/tmp/\${0##*/}.log 2>&1
set -\${DX} # Are you going to debug? (DX is set to 'x' (set DX='x') or unset)
fi
#
date > /home/rein/getAndBuild.run.time
cd /home/rein/bin
mv mvGet2here mvGet2here.done
sudo mv /media/sf_VM-sfolder/build/vr_genetlink.c.new /home/rein/src
sudo chown rein:rein /home/rein/src/vr_genetlink.c.new
sudo chmod a-wx,a+r,u+w /home/rein/src/vr_genetlink.c.new
cd /home/rein
echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
sudo dpkg --configure -a
sudo apt-get update
# sudo apt-get -y install autoconf automake bison debhelper flex libcurl4-openssl-dev libexpat1-dev libgettextpo0 libprotobuf-dev libtool libxml2-utils make protobuf-compiler python-all python-lxml python-setuptools python-sphinx ruby-ronn scons unzip vim-common python-netsnmp librdkafka-dev librdkafka1
sudo apt-get -y install autoconf automake bison debhelper flex libcurl4-openssl-dev libexpat1-dev libgettextpo0 libprotobuf-dev libtool libxml2-utils make protobuf-compiler python-all python-lxml python-setuptools python-sphinx ruby-ronn scons unzip vim-common python-netsnmp
sudo apt-get -y install python-dev
sudo apt-get -y install libfixbuf3-dev
sudo apt-get -y install xz-utils cpio pax
sudo apt-get -y install libncurses5-dev
sudo apt-get -y install libssl-dev
sudo mv /media/sf_VM-sfolder/build/libssl1.0.0_1.0.2g-1ubuntu4_amd64.deb .
sudo apt-get -f install
sudo apt-get -y install git
sudo apt-get -y install g++ g++-multilib
# sudo apt-get -y install gcc-4.9-plugin-dev
sudo apt-get -y install gcc-5-plugin-dev
sudo apt-get -y --no-install-recommends install dselect build-essential fakeroot kernel-package
sudo apt-get -y install libboost-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libcurl4-openssl-dev google-mock libgoogle-perftools-dev liblog4cplus-dev libtbb-dev libhttp-parser-dev libxml2-dev libicu-dev
# sudo apt-get -y install libuv1 libuv1-dev
sudo apt-get -y install libpcap-dev
sudo apt-get -y install libnl-3-200 libnl-3-dev libnl-genl-3-200 libnl-genl-3-dev
sudo apt-get -y install cmake cmake-data cmake-extras
sudo apt-get -y install w3m
sudo apt-get -y install repo
sudo apt-get -y install nmon
sudo apt-get -y -f install
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo rm -f /media/sf_VM-sfolder/build/dpkg-gencontrol
date >> /home/rein/getAndBuild.run.time
MAKEOPTIES="--jobs \$(nproc) V=1 -d"
mkdir -p src/Linux
cd src/Linux
# git clone ${KERNELSET}
# git clone ${CONFIGFILE}
# cd ~/src/Linux/build
# ln -s ../Kernel source
# if make \${MAKEOPTIES} prepare > make.prepare.lst 2>&1
# then
# if make \${MAKEOPTIES} modules > make.modules.lst 2>&1
# then
# if make \${MAKEOPTIES} all > make.all.lst 2>&1
# then
# if sudo make \${MAKEOPTIES} modules_install > make.modules_install.lst 2>&1
# then
# if sudo make \${MAKEOPTIES} headers_install > make.headers_install.lst 2>&1
# then
# if sudo make \${MAKEOPTIES} install > make.install.lst 2>&1
# then
# VERSION=\$(cat include/config/kernel.release)
# cd /boot
# sudo update-grub
# sudo update-initramfs -c -k \${VERSION}
# sudo update-grub
# sudo update-initramfs -u -k \${VERSION}
# sudo update-grub
# fi
# fi
# fi
# fi
# fi
# fi
date >> /home/rein/getAndBuild.run.time
# cd ~/src/Linux/build
# KR=\$(cat include/config/kernel.release)
KR=\$(uname -r)
echo \${KR} > ~/kernel.version
# sudo mkdir -p /usr/src/linux-headers-\${KR}
# sudo cp -a * /usr/src/linux-headers-\${KR}/
# cd /usr/src/
# sudo chown -R root:root linux-headers-\${KR}
date >> /home/rein/getAndBuild.run.time
echo "JuniperControllerBuild" > next
sleep 5
sudo reboot
EOF
chmod 777 getAndBuild
mkdir -p ~/VM-sfolder/build
cp getAndBuild ~/VM-sfolder/build
cp .gitconfig ~/VM-sfolder/build
cp dpkg-gencontrol ~/VM-sfolder/build
cp vr_genetlink.c.new ~/VM-sfolder/build
#cp JuniperVRouterBuild ~/VM-sfolder/build
cp openssl-1.1.0f.tar.gz ~/VM-sfolder/build
cp libipfix_110209.tgz ~/VM-sfolder/build
cp JuniperControllerBuild ~/VM-sfolder/build
cp mpackages.xml ~/VM-sfolder/build
BUILDERNAME="build-${CLONENAME}"
UUID=$(${VBOXMANAGE} showvminfo builder|grep 'Hardware UUID:'|cut -f5 -d' ')
${VBOXMANAGE} clonevm --mode all --name "${BUILDERNAME}" --register "${UUID}"
${VBOXMANAGE} startvm "${BUILDERNAME}" --type headless
echo "To connet to the VM use: ssh \$(getVMIPAddress ${BUILDERNAME})"
sudo rm -f .gitconfig flg.building getAndBuild