Last active
January 27, 2019 00:02
-
-
Save dalehamel/15efcf02e6fd7999b5a151cd2b5702e8 to your computer and use it in GitHub Desktop.
Fetch containeros linux headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LSB_FILE="/mnt/root/etc/lsb-release" | |
OS_RELEASE_FILE="/mnt/root/etc/os-release" | |
generate_headers() | |
{ | |
echo "Generating kernel headers" | |
cd ${SOURCES_DIR} | |
zcat /proc/config.gz > .config | |
make oldconfig > /dev/null | |
make prepare > /dev/null | |
} | |
fetch_cos_linux_sources() | |
{ | |
if [ ! -e "${SOURCES_DIR}/.fetched" ];then | |
echo "Fetching upstream kernel sources." | |
mkdir -p ${SOURCES_DIR} | |
curl -s "https://storage.googleapis.com/cos-tools/${BUILD_ID}/kernel-src.tar.gz" | tar -xzf - -C ${SOURCES_DIR} | |
touch "${SOURCES_DIR}/.fetched" | |
fi | |
} | |
install_cos_linux_headers() | |
{ | |
if grep -q CHROMEOS_RELEASE_VERSION ${LSB_FILE};then | |
BUILD_ID=$(grep CHROMEOS_RELEASE_VERSION ${LSB_FILE} | cut -d = -f 2) | |
SOURCES_DIR="/usr/src/linux-lakitu-${BUILD_ID}" | |
if [ ! -e "${SOURCES_DIR}/.installed" ];then | |
echo "Installing kernel headers for for COS build ${BUILD_ID}" | |
fetch_cos_linux_sources | |
generate_headers | |
touch "${SOURCES_DIR}/.installed" | |
fi | |
fi | |
} | |
distro=$(grep ^NAME ${OS_RELEASE_FILE} | cut -d = -f 2) | |
case $distro in | |
*"Container-Optimized OS"*) | |
install_cos_linux_headers | |
;; | |
*) | |
echo "WARNING: ${distro} is not a supported distro, cannot install headers, ensure they are installed to /lib/modules" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment