Last active
January 14, 2020 21:31
-
-
Save mikhailnov/48235b3e4ab8d1729f65bdc76c150594 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
set -efu | |
export DEBIAN_FRONTEND=noninteractive | |
FALLBACK=0 | |
APT_MAIN=0 | |
DONE=0 | |
khpkg="" | |
kernel="$(uname -r || :)" | |
if [ -z "$kernel" ]; then | |
echo "Unable to get kernel version, trying fallback" | |
FALLBACK=1 | |
fi | |
if [ "$FALLBACK" = 0 ] && [ ! -d "/lib/modules/${kernel}/kernel" ]; then | |
echo "Detected kernel not found on this sytem, probably running in container?" | |
echo "Trying fallback" | |
FALLBACK=1 | |
fi | |
if [ "$FALLBACK" = 0 ]; then | |
khpkg="linux-headers-${kernel}" | |
if ! LC_ALL=C apt policy "$khpkg" | grep -q 'Unable to locate package' | |
then APT_MAIN=0 | |
else APT_MAIN=1 | |
fi | |
fi | |
if [ "$APT_MAIN" = 1 ]; then | |
if apt install -y "$khpkg" ; then | |
DONE=1 | |
fi | |
fi | |
if [ "$DONE" = 0 ]; then | |
if apt install "blablabla" ; then | |
DONE=1 | |
fi | |
fi | |
if [ "$DONE" = 0 ]; then | |
echo "Error" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment