3 # lnet This shell script takes care of starting and stopping
4 # the lnet (Lustre networking) services.
7 # description: Part of the lustre file system.
9 # config: /etc/sysconfig/lnet
11 # Source function library.
12 [ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
14 # Source networking configuration and check that networking is up.
15 [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network && \
16 [ "${NETWORKING}" = "no" ] && exit 0
18 # Check for and source configuration file otherwise set defaults
19 [ -f /etc/sysconfig/lnet ] && . /etc/sysconfig/lnet
21 declare -r awkprog='BEGIN { rc = -1 }
22 { if ( $1 == module_name ) { rc = $3; exit; } }
25 # Usage: run_preexec_check [ start | restart | condrestart ]
26 # The single parameter will be passed to the PREEXEC_SCRIPT
29 if [ -n "$PREEXEC_CHECK" ] && ! $PREEXEC_CHECK ; then
30 echo "Pre-exec check \"$PREEXEC_CHECK\" failed. Aborting."
34 if [ -n "$PREEXEC_SCRIPT" ] && ! "$PREEXEC_SCRIPT" "$1" ; then
35 echo "Pre-exec script \"$PREEXEC_SCRIPT\" failed. Aborting."
40 # Usage: run_postexec_check [ start | restart | condrestart ]
41 # The single parameter will be passed to the POSTEXEC_SCRIPT
44 if [ -n "$POSTEXEC_CHECK" ] && ! $POSTEXEC_CHECK ; then
45 echo "Post-exec check \"$POSTEXEC_CHECK\" failed. Aborting."
49 if [ -n "$POSTEXEC_SCRIPT" ] && ! "$POSTEXEC_SCRIPT" "$1" ; then
50 echo "Post-exec script \"$POSTEXEC_SCRIPT\" failed. Aborting."
57 old_nullglob="`shopt -p nullglob`"
61 # LSB compliance - return 3 if service is not running
62 # Lustre-specific returns
63 # 150 - partial startup
64 # 151 - health_check unhealthy
67 egrep -q "lnet" /proc/modules && STATE="loaded"
69 # check for any routes - on a portals router this is the only thing
70 VAR=$(lctl get_param -n routes 2>&1)
76 # check if this is a router
77 if [[ "$(lctl get_param -n routes)" =~ "Routing enabled" ]]; then
82 # check for error in health_check
83 local health_check=$(lctl get_param -n health_check)
84 if [[ "$health_check" =~ "NOT HEALTHY" ]]; then
89 if [[ "$health_check" =~ "LBUG" ]]; then
98 # See how we were called.
101 run_preexec_check "start"
102 touch /var/lock/subsys/lnet
103 modprobe lnet || exit 1
104 @BUILD_DLC_TRUE@lnetctl lnet configure || exit 1
105 @BUILD_DLC_TRUE@lnetctl import < "@sysconfdir@/lnet.conf"
106 @BUILD_DLC_FALSE@lctl network up || exit 1
107 @BUILD_DLC_FALSE@lustre_routes_config "@sysconfdir@/lnet_routes.conf"
108 run_postexec_check "start"
111 run_preexec_check "stop"
112 lustre_rmmod ptlrpc || exit 1
113 @BUILD_DLC_TRUE@lnetctl lnet unconfigure || exit 1
114 @BUILD_DLC_FALSE@lctl network down || exit 1
115 lustre_rmmod libcfs ldiskfs || exit 1
116 rm -f /var/lock/subsys/lnet
117 run_postexec_check "stop"
127 touch /var/lock/subsys/lnet
130 if [ ! -f /var/lock/subsys/lnet ] ; then
131 echo $"start"; exit 0
135 [ -f /var/lock/subsys/lnet ] && {
141 echo $"Usage: lnet {start|stop|status|restart|reload|condrestart}"