3 # $Id: lnet.rc bogl Exp $
7 # Required-Start: $network openibd
8 # Required-Stop: $network openibd
10 # Default-Stop: 0 1 2 5 6
11 # Description: Enable Lustre Networking
14 # lnet This shell script takes care of starting and stopping
15 # the lnet (Lustre networking) services.
18 # description: Part of the lustre file system.
20 # config: /etc/sysconfig/lnet
22 # Source function library.
23 [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
25 # Source networking configuration and check that networking is up.
26 [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network && \
27 [ "${NETWORKING}" = "no" ] && exit 0
29 # Check for and source configuration file otherwise set defaults
30 [ -f /etc/sysconfig/lnet ] && . /etc/sysconfig/lnet
32 declare -r awkprog='BEGIN { rc = -1 }
33 { if ( $1 == module_name ) { rc = $3; exit; } }
36 # Usage: run_preexec_check [ start | restart | condrestart ]
37 # The single parameter will be passed to the PREEXEC_SCRIPT
40 if [ -n "$PREEXEC_CHECK" ] && ! $PREEXEC_CHECK ; then
41 echo "Pre-exec check \"$PREEXEC_CHECK\" failed. Aborting."
45 if [ -n "$PREEXEC_SCRIPT" ] && ! "$PREEXEC_SCRIPT" "$1" ; then
46 echo "Pre-exec script \"$PREEXEC_SCRIPT\" failed. Aborting."
51 # Usage: run_postexec_check [ start | restart | condrestart ]
52 # The single parameter will be passed to the POSTEXEC_SCRIPT
55 if [ -n "$POSTEXEC_CHECK" ] && ! $POSTEXEC_CHECK ; then
56 echo "Post-exec check \"$POSTEXEC_CHECK\" failed. Aborting."
60 if [ -n "$POSTEXEC_SCRIPT" ] && ! "$POSTEXEC_SCRIPT" "$1" ; then
61 echo "Post-exec script \"$POSTEXEC_SCRIPT\" failed. Aborting."
68 old_nullglob="`shopt -p nullglob`"
72 # LSB compliance - return 3 if service is not running
73 # Lustre-specific returns
74 # 150 - partial startup
75 # 151 - health_check unhealthy
78 egrep -q "lnet" /proc/modules && STATE="loaded"
80 # check for any routes - on a portals router this is the only thing
81 VAR=$(lctl get_param -n routes 2>&1)
87 # check if this is a router
88 if [[ "$(lctl get_param -n routes)" =~ "Routing enabled" ]]; then
93 # check for error in health_check
94 local health_check=$(lctl get_param -n health_check)
95 if [[ "$health_check" =~ "NOT HEALTHY" ]]; then
100 if [[ "$health_check" =~ "LBUG" ]]; then
109 # See how we were called.
112 run_preexec_check "start"
113 touch /var/lock/subsys/lnet
114 modprobe lnet || exit 1
115 lnetctl lnet configure || exit 1
116 lnetctl import < "@sysconfdir@/lnet.conf"
117 run_postexec_check "start"
120 run_preexec_check "stop"
121 lustre_rmmod ptlrpc || exit 1
122 lnetctl lnet unconfigure || exit 1
123 lustre_rmmod libcfs ldiskfs || exit 1
124 rm -f /var/lock/subsys/lnet
125 run_postexec_check "stop"
135 touch /var/lock/subsys/lnet
138 if [ ! -f /var/lock/subsys/lnet ] ; then
139 echo $"start"; exit 0
143 [ -f /var/lock/subsys/lnet ] && {
149 echo $"Usage: lnet {start|stop|status|restart|reload|condrestart}"