-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupnetconsole.sh
More file actions
61 lines (49 loc) · 1.85 KB
/
Copy pathsetupnetconsole.sh
File metadata and controls
61 lines (49 loc) · 1.85 KB
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
#!/bin/bash
#
# setupnetconsole.sh
# a script to setup netconsole
#
# just set these variables and you're good to go
LEVEL="8"
LOCALDEV="em1"
REMOTEIP="10.0.0.0"
REMOTEMAC="00:00:00:00:00:00"
# if the remoteip is not in the same subnet, use the gateway's mac so traffic routes
echo "raising kernel logging level to $LEVEL"
dmesg -n "$LEVEL"
if [ "$(lsmod | grep -c configfs)" -gt 0 ]; then
echo "configfs already loaded"
else
echo "loading configfs"
modprobe configfs
fi
if [ "$(lsmod | grep -c netconsole)" -gt 0 ]; then
echo "netconsole already loaded"
else
echo "loading netconsole"
modprobe netconsole
fi
if [ "$(mount | grep -c "type configfs")" -gt 0 ]; then
echo "configfs already mounted"
else
echo "mounting configfs"
mount none -t configfs /sys/kernel/config
fi
# setup a target
if [ -d /sys/kernel/config/netconsole/target1 ]; then
echo "netconsole target directory already exists"
else
echo "making netconsole target directory"
mkdir /sys/kernel/config/netconsole/target1
fi
echo "0" > /sys/kernel/config/netconsole/target1/enabled
echo "$LOCALDEV" > /sys/kernel/config/netconsole/target1/dev_name
echo -n "/sys/kernel/config/netconsole/target1/dev_name = "; cat /sys/kernel/config/netconsole/target1/dev_name
echo "$(ifdata -pa "$LOCALDEV")" > /sys/kernel/config/netconsole/target1/local_ip
echo -n "/sys/kernel/config/netconsole/target1/local_ip = "; cat /sys/kernel/config/netconsole/target1/local_ip
echo "$REMOTEIP" > /sys/kernel/config/netconsole/target1/remote_ip
echo -n "/sys/kernel/config/netconsole/target1/remote_ip = "; cat /sys/kernel/config/netconsole/target1/remote_ip
echo "$REMOTEMAC" > /sys/kernel/config/netconsole/target1/remote_mac
echo -n "/sys/kernel/config/netconsole/target1/remote_mac = "; cat /sys/kernel/config/netconsole/target1/remote_mac
echo "enabling..."
echo "1" > /sys/kernel/config/netconsole/target1/enabled