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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
#!/bin/sh
#
# Copyright(c) 2011 Ritesh Raj Sarraf
# Copyright(c) 2010 Intel Corporation. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
#
#
# Derived from the Upstream Script
### BEGIN INIT INFO
# Provides: fcoe-utils
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs sendsigs
# Default-Start: S
# Default-Stop: 0 1 6
# Short-Description: Starts and Stops the Open-FCoE Initiator
# Description: Open FCoE Initiator
### END INIT INFO
CONFIG_DIR=/etc/fcoe
PID_FILE="/var/run/fcoemon.pid"
LOG_FILE="/var/log/fcoemon.log"
FCOEMON=/usr/sbin/fcoemon
FCOEADM=/usr/sbin/fcoeadm
FCOEMON_OPTS=
. /lib/lsb/init-functions
. $CONFIG_DIR/config
if [ "$USE_SYSLOG" = "yes" ] || [ "$USE_SYSLOG" = "YES" ]; then
FCOEMON_OPTS="$FCOEMON_OPTS --syslog"
fi
if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then
FCOEMON_OPTS="$FCOEMON_OPTS --debug"
fi
test -x $FCOEADM || {
if [ "$1" = "stop" ]; then exit 0;
else
log_failure_msg "fcoeadm tool not installed."
exit 1;
fi
}
test -x $FCOEMON || {
echo "$FCOEMON not installed";
if [ "$1" = "stop" ]; then exit 0;
else
log_failure_msg "fcoemon tool not installed."
exit 1;
fi
}
start()
{
log_daemon_msg "Starting FCoE initiator service"
modprobe -q libfc 2>/dev/null || :
modprobe -q fcoe 2>/dev/null || :
start-stop-daemon --start --quiet --pidfile $PID_FILE --exec ${FCOEMON} -- ${FCOEMON_OPTS}
touch /var/lock/fcoe
log_end_msg 0;
}
stop()
{
local force=$1
pid=$(pidof "$FCOEMON")
if [ "$force" = "force" ]
then
log_warning_msg "Destroying any active fcoe interface/s"
[ "$pid" ] && kill -HUP $pid
log_end_msg 0;
else
[ "$pid" ] && kill -TERM $pid
fi
log_daemon_msg "Stopping FCoE initiator service"
rm -f /var/run/fcoemon.*
rm -f /tmp/fcoemon.dcbd.*
rm -f /var/lock/fcoe
log_end_msg 0;
}
status()
{
status=0
pidof $FCOEMON
if [ $? -eq 0 ]; then
log_daemon_msg "$FCOEMON -- RUNNING, pid=`cat $PID_FILE`"
else
log_daemon_msg "$FCOEMON -- UNUSED"
status=3
fi
log_end_msg 0;
interfaces=`$FCOEADM -i 2>&1 | \
awk '/Symbolic Name:/{print $6}' | \
sort | awk '{printf("%s ", $1)}'`
if [ -z "$interfaces" ]; then
log_daemon_msg "No interfaces created."
else
log_daemon_msg "Created interfaces: $interfaces"
status=0
fi
if [ -f /var/lock/fcoe -a $status -eq 3 ]; then
status=2
fi
if [ -f /var/run/fcoe.pid -a $status -eq 3 ]; then
status=1
fi
return $status
}
case "$1" in
start)
start
;;
stop)
stop $2
;;
restart)
stop $2
start
;;
force-reload)
stop force
start
;;
status)
status
exit $?
;;
condrestart|try-restart)
status || exit 0
$0 restart
;;
*)
echo -n "Usage: $0 {start|stop [force]|status|restart [force]|"
echo "force-reload|condrestart|try-restart}"
exit 1
;;
esac
|