| 1 | #!/bin/bash |
| 2 | |
| 3 | #*********************************************************************** |
| 4 | # * The langford initialization file. This utility initializes the |
| 5 | # * /dev/langford file based on the /proc/device list. |
| 6 | # * |
| 7 | # * (c) 2013 Per Vices Corporation |
| 8 | # * |
| 9 | # * See LICENSE.txt for license and copyright information. |
| 10 | # ************************************************************************/ |
| 11 | |
| 12 | #Load registered char device to /dev/langford |
| 13 | #This will only work after compiling correct kernel driver. |
| 14 | |
| 15 | #Check for root permissions - required to create char device. |
| 16 | if [[ $EUID -ne 0 ]]; then |
| 17 | echo "Langford device initialization requires superuser permissions. Please run as root, or try typing: sudo langford_init" 1>&2 |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | |
| 22 | if [ -e /dev/langford ]; then |
| 23 | echo "/dev/langford already exists - exiting." |
| 24 | exit 1 |
| 25 | else |
| 26 | mknod /dev/langford c $(awk '/langford/ {print $1}' /proc/devices) 0 |
| 27 | if [ -e /dev/langford ] |
| 28 | then |
| 29 | # echo "New Langford Device Created at /dev/langford" |
| 30 | chown root:langford /dev/langford |
| 31 | chmod g+u /dev/langford |
| 32 | # echo "Granting read/write permissions to members of the langford group." |
| 33 | exit 0 |
| 34 | else |
| 35 | echo "Failed to create Langford device. Is the kernel module loaded?" |
| 36 | exit 1 |
| 37 | fi |
| 38 | fi |
| 39 |