|
1 #!/bin/bash |
|
2 #$Header: /usr/local/cvsroot/3GNetworkEmulator/Source/UUInterface/Load.Nistnet,v 1.1 2003/11/17 16:17:02 penuser Exp $ |
|
3 # Script to load the kernel module, saving the rtc if possible |
|
4 # |
|
5 # Mark Carson, NIST/UMCP |
|
6 # 1/2001 |
|
7 |
|
8 # Surely there's a better way to do this... |
|
9 versionstring=`uname -r | sed 's/\./ /g'` |
|
10 read version0 version1 version2 << below |
|
11 $versionstring |
|
12 below |
|
13 |
|
14 case $version0 in |
|
15 2) |
|
16 ;; |
|
17 *) |
|
18 echo Sorry, NIST Net runs only on 2.0.xx or 2.2.xx kernels |
|
19 exit 1 |
|
20 ;; |
|
21 esac |
|
22 |
|
23 # This no doubt is not the way to find the system map |
|
24 # for the current kernel, but hopefully it will do. |
|
25 if [ -r /System.map ] ; then |
|
26 map=/System.map |
|
27 elif [ -r /boot/System.map ] ; then |
|
28 map=/boot/System.map |
|
29 elif [ -r /usr/src/linux/System.map ] ; then |
|
30 map=/usr/src/linux/System.map |
|
31 fi |
|
32 |
|
33 case $version1 in |
|
34 0) |
|
35 # Look for irq_action - why doesn't a pipe work? Sheesh... |
|
36 grep irq_action $map > /tmp/j$$ |
|
37 read irq_action junk < /tmp/j$$ |
|
38 rm /tmp/j$$ |
|
39 if [ "$irq_action" != "" ] ; then |
|
40 insmod nistnet irq_desc_addr=0x$irq_action |
|
41 else |
|
42 insmod nistnet |
|
43 fi |
|
44 ;; |
|
45 2) |
|
46 # Look for irq_desc - why doesn't a pipe work? Sheesh... |
|
47 grep irq_desc $map > /tmp/j$$ |
|
48 read irq_desc junk < /tmp/j$$ |
|
49 rm /tmp/j$$ |
|
50 if [ "$irq_desc" != "" ] ; then |
|
51 insmod nistnet irq_desc_addr=0x$irq_desc |
|
52 else |
|
53 insmod nistnet |
|
54 fi |
|
55 ;; |
|
56 4) |
|
57 # Try to remove rtc module |
|
58 rmmod rtc |
|
59 if [ $? != 0 ] ; then |
|
60 echo "Couldn't find rtc module - /dev/rtc will be mostly" |
|
61 echo "unusable after running nistnet. Sorry about that...." |
|
62 echo "To prevent this message, recompile rtc" |
|
63 echo "(Enhanced Real Time Clock Support, under" |
|
64 echo "character devices) as a module." |
|
65 else |
|
66 echo "rtc module removed - you may want to reinstall it" |
|
67 echo "(with insmod rtc) after you are done with nistnet" |
|
68 fi |
|
69 |
|
70 insmod nistnet |
|
71 echo "nistnet module installed" |
|
72 ;; |
|
73 *) |
|
74 echo Sorry, NIST Net runs only on 2.0, 2.2 or 2.4 kernels |
|
75 exit 1 |
|
76 ;; |
|
77 esac |
|
78 |
|
79 exit 0 |