fm10k-rdif-setup/setup.sh

72 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
set -e
SCRIPT_DIR=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
pushd "${SCRIPT_DIR}"
if [[ -d ".git" ]]; then
git submodule update --init --recursive
fi
pushd deps
if ! command -v dkms &> /dev/null; then
echo "DKMS not found, falling back to manual build"
pushd fm10k/src
make clean
make -j $(nproc) CONFIG_UIO=1
make install CONFIG_UIO=1
if ! command -v rdif &> /dev/null; then
rdif stop
fi
modprobe uio
#Reload FM10K kernel module
rmmod fm10k
modprobe fm10k
popd
else
pushd fm10k
DKMS_VERSION=$(grep "PACKAGE_VERSION=" dkms.conf)
DKMS_VERSION=${DKMS_VERSION#*=}
if [[ $(dkms status -m "fm10k/${DKMS_VERSION}") != "" ]]; then
dkms remove -m "fm10k/${DKMS_VERSION}" --all
fi
if [[ -d "/usr/src/fm10k-${DKMS_VERSION}/" ]]; then
rm -R "/usr/src/fm10k-${DKMS_VERSION}/"
fi
cp -R . "/usr/src/fm10k-${DKMS_VERSION}/"
dkms add -m "fm10k/${DKMS_VERSION}" "$(pwd)"
dkms build -m "fm10k/${DKMS_VERSION}"
#Build for all kernels
ls /var/lib/initramfs-tools | \
sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start
popd
fi
pushd rdif
./clean
./install
popd
popd
if [ ! -d /etc/rdi ]; then
mkdir /etc/rdi
fi
if [ ! -f /etc/rdi/fm_platform_attributes.cfg ]; then
cp -v platform/default/fm_platform_attributes.cfg /etc/rdi/fm_platform_attributes.cfg
fi