#!/bin/bash MODULE=hello DEVICE=skull MODE=664 # invoke insmod with all arguments and use a pathname # as newer modutils don't look into . by default /usr/bin/insmod ./${MODULE}.ko $* || exit 1 # remove stale nodes rm -f /dev/${DEVICE}[0] MAJOR=$(awk "\$2 == \"$DEVICE\" {print \$1}" /proc/devices) mknod /dev/${DEVICE}0 c $MAJOR 0 # give appriopriate permissions GROUP=staff grep -q '^staff' /etc/group || GROUP=wheel chgrp $GROUP /dev/${DEVICE}0 chmod $MODE /dev/${DEVICE}0