#!/bin/sh
# $Id: gpio_load,v 1.1 2006/09/21 12:38:05 papps Exp $
module="gpio"
device="gpio"
mode="664"

# Group: since distributions do it differently, look for wheel or use staff
if grep -q '^staff:' /etc/group; then
    group="staff"
else
    group="wheel"
fi

# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default
/sbin/insmod ./$module.ko $* || exit 1

# retrieve major number
major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)

#echo "Major number $major, and group $group"

# Remove any stale node
rm -f /dev/${device}

# Create a new node for gpio
mknod /dev/${device} c $major 0

# Set nodes gid and permissions
chgrp $group /dev/${device}
chmod $mode  /dev/${device}

echo "gpio loaded"





