1
0
mirror of https://github.com/krislamo/kernmod.git synced 2024-11-10 00:30:36 +00:00
kernmod/build.sh

29 lines
822 B
Bash
Raw Normal View History

2021-11-10 06:14:16 +00:00
#!/bin/bash
2022-01-14 06:54:13 +00:00
VERSION="0.1"
# Install build prerequisites
2021-11-10 06:14:16 +00:00
export DEBIAN_FRONTEND=noninteractive
apt-get update
2022-01-14 06:54:13 +00:00
apt-get install -y dkms build-essential linux-headers-$(uname -r)
2021-11-10 06:14:16 +00:00
2022-01-14 06:54:13 +00:00
# Place source and configuration files on the system
2021-11-10 06:14:16 +00:00
cd /vagrant
2022-01-14 06:54:13 +00:00
mkdir /usr/src/helloworld-$VERSION
cp Makefile /usr/src/helloworld-$VERSION/Makefile
cp helloworld.c /usr/src/helloworld-$VERSION/helloworld.c
cp dkms.conf /usr/src/helloworld-$VERSION/dkms.conf
cp helloworld.conf /etc/modules-load.d/helloworld.conf
# Build and install kernel module with DKMS
dkms add -m helloworld -v $VERSION
dkms build -m helloworld -v $VERSION
dkms install -m helloworld -v $VERSION
# Load module and show details about it
modprobe helloworld
modinfo helloworld
2021-11-10 06:14:16 +00:00
cat /proc/modules | grep helloworld
rmmod helloworld
cat /var/log/messages | grep helloworld