Skip to content

Instantly share code, notes, and snippets.

@alexlovelltroy
Created April 25, 2019 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlovelltroy/1524f281bc3b2aa369229ffd2f1b9518 to your computer and use it in GitHub Desktop.
Save alexlovelltroy/1524f281bc3b2aa369229ffd2f1b9518 to your computer and use it in GitHub Desktop.
from debian:stretch-slim as builder
RUN apt-get -y update
RUN apt-get -y install build-essential linux-headers-$(uname -r)
RUN apt-get -y install debhelper dkms kmod unzip
RUN curl -LO https://github.com/milesp20/intel_nuc_led/archive/master.zip && unzip master.zip
RUN cd intel_nuc_led-master && make clean && make dkms-install
from alpine as base
RUN apk update --no-cache && apk add kmod --no-cache
COPY safe_load_modules.sh /root/
from base
RUN mkdir -p /root/4.9.0-7-amd64/
COPY --from=builder /lib/modules/4.9.0-7-amd64/updates/dkms/nuc_led.ko /root/4.9.0-7-amd64/nuc_led-1.0.ko
VOLUME /writeable_proc
WORKDIR /root/
ENV COLOR=blue
CMD ["./safe_load_modules.sh","nuc_led-1.0.ko"]
#!/bin/sh
"${COLOR?Need to set COLOR}"
KERNEL_VERSION=`uname -r`
MODULE_VERSION=`modinfo -F vermagic $KERNEL_VERSION/$1 |cut -f1 -d' '`
echo "$KERNEL_VERSION = $MODULE_VERSION"
if [ "$KERNEL_VERSION" = "$MODULE_VERSION" ] ; then
echo "adding $1 to the kernel"
insmod $KERNEL_VERSION/$1
fi
echo "ring,80,blink_medium,$COLOR" > /writable_proc/acpi/nuc_led

Build the container

docker build -t nuc_driver_container .

Run the container

docker run --cap-add SYS_MODULE -v /proc:/writable_proc -e COLOR=cyan -it --rm nuc_driver_container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment