#!/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