summaryrefslogtreecommitdiffstats
path: root/stp_check
blob: 0c49d3e7dd52ec9ab761f4afae09970da4dbe872 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash

load_module()
{
    ret=1
    if [ -e "$MODULE" ]
    then
	/sbin/insmod $MODULE
	ret=$?
    fi
	
    if [ "$ret" -ne 0 ]
    then
	echo "$MODULE_NAME not in kernel and not built.  Compiling..."
	make -w -C $MODULE_DIR
	if [ "$?" -ne 0 ]
	then
	    echo "Failed to load module $MODULE_NAME."
	    exit $?
	fi

	/sbin/insmod $MODULE
	if [ "$?" -ne 0 ]
	then
	    echo "Failed to load module $MODULE_NAME."
	    exit $?
	fi
    fi
}

VAR_DIR=${prefix}/var/lib/systemtap
RELAYFS_DIR=$VAR_DIR/relayfs
STP_CONTROL_DIR=$VAR_DIR/transport

RELAYFS=`grep " relayfs_poll" /boot/System.map-\`uname -r\``
if [ -z "$RELAYFS" ]
then
    RELAYFS=`lsmod | grep relayfs`
    if [ -z "$RELAYFS" ]
    then
	MODULE_NAME=relayfs
	MODULE_DIR=$RELAYFS_DIR
	MODULE=$MODULE_DIR/relayfs.ko
	load_module
    fi
fi

if [ ! -d "/mnt/relay" ]
then
    mkdir /mnt/relay
fi

MOUNT=`mount | grep relayfs |awk '{print $1}'`
if [ "$MOUNT" != "relayfs" ]
then
	mount -t relayfs relayfs /mnt/relay
fi

STP_CONTROL=`lsmod | grep stp_control |awk '{print $1}'`
if [ "$STP_CONTROL" != "stp_control" ] 
then
    MODULE_NAME=stp-control
    MODULE_DIR=$STP_CONTROL_DIR
    MODULE=$MODULE_DIR/stp-control.ko
    load_module
fi