-
Notifications
You must be signed in to change notification settings - Fork 4
/
i40e-lldp-agent.init
119 lines (101 loc) · 2.42 KB
/
i40e-lldp-agent.init
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# i40e-lldp-agent Manage x710 lldp agent
#
# chkconfig: - 20 80
# description: Enables or disabled the lldp agent on x710 intel converged \
# network adaptors
### BEGIN INIT INFO
# Provides:
# Required-Start: $network
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Manage x710 lldp agent
# Description: Enables or disabled the lldp agent on x710 intel converged
# network adaptors
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
SCRIPT=i40e-lldp-agent
_lldp_switch(){
if [ ! -d /sys/module/i40e ] ; then
echo -n "${SCRIPT}: i40e driver not loaded. "
success
exit 0
fi
action=$1
if [[ ! "$action" =~ ^(start|stop)$ ]]; then
(echo "${SCRIPT}: Invalid action \"$action\"" ; exit 2)
fi
echo "${SCRIPT}: ${action} disabling embedded lldp in x710"
do_unmount=false
if ! grep -q ' /sys/kernel/debug ' /etc/mtab ; then
echo -n "${SCRIPT}: Mount /sys/kernel/debug. "
mount -t debugfs none /sys/kernel/debug && success || failure
echo
do_unmount=true
fi
for IFACE_DEBUG_PATH in /sys/kernel/debug/i40e/*
do
echo -n "${SCRIPT}: $action on $(cat ${IFACE_DEBUG_PATH}/command)"
echo lldp $action > ${IFACE_DEBUG_PATH}/command
success
echo
done
if $do_unmount; then
if grep -q ' /sys/kernel/debug ' /etc/mtab ; then
echo -n "${SCRIPT}: Unmount /sys/kernel/debug. "
umount /sys/kernel/debug && success || failure
echo
fi
fi
retval=0
return $retval
}
start() {
_lldp_switch start
retval=$?
return $retval
}
stop() {
_lldp_switch stop
retval=$?
return $retval
}
restart() {
stop
start
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
#rh_status_q && exit 0
$1
;;
stop)
#rh_status_q || exit 0
$1
;;
restart)
$1
;;
status)
# TODO: need to work out how to see if x710 lldp agent is turned on
echo "${SCRIPT}: who knows what the status is?"
#rh_status
exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?