"Fossies" - the Fresh Open Source Software Archive

Member "open-fcoe-3.19/fcoe-utils/etc/initd/initd.fedora" (15 Apr 2015, 3023 Bytes) of package /linux/misc/open-fcoe-3.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 # Copyright(c) 2010-2011 Intel Corporation. All rights reserved.
    4 #
    5 # This program is free software; you can redistribute it and/or modify it
    6 # under the terms and conditions of the GNU General Public License,
    7 # version 2, as published by the Free Software Foundation.
    8 #
    9 # This program is distributed in the hope it will be useful, but WITHOUT
   10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   12 # more details.
   13 #
   14 # You should have received a copy of the GNU General Public License along with
   15 # this program; if not, write to the Free Software Foundation, Inc.,
   16 # 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
   17 #
   18 # chkconfig: - 21 80
   19 #
   20 # Maintained at www.Open-FCoE.org
   21 
   22 ### BEGIN INIT INFO
   23 # Provides: fcoe
   24 # Required-Start: network
   25 # Required-Stop:
   26 # Default-Start:
   27 # Default-Stop:
   28 # Short-Description: Open-FCoE Initiator
   29 # Description: Open-FCoE Initiator
   30 ### END INIT INFO
   31 
   32 CONFIG_DIR=/etc/fcoe
   33 LOG_FILE="/var/log/fcoemon.log"
   34 LOCKFILE="/var/lock/subsys/fcoe"
   35 FCOEMON=/usr/sbin/fcoemon
   36 FCOEADM=/usr/sbin/fcoeadm
   37 FCOEMON_OPTS=
   38 
   39 . /etc/init.d/functions
   40 . $CONFIG_DIR/config
   41 
   42 if [ "$USE_SYSLOG" = "yes" ] || [ "$USE_SYSLOG" = "YES" ]; then
   43     FCOEMON_OPTS+=" --syslog"
   44 fi
   45 
   46 if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then
   47     FCOEMON_OPTS+=" --debug"
   48 fi
   49 
   50 test -x $FCOEADM || {
   51     echo "$FCOEADM not installed";
   52     if [ "$1" = "stop" ]; then exit 0;
   53     else
   54         failure
   55     fi
   56 }
   57 
   58 test -x $FCOEMON || {
   59     echo "$FCOEMON not installed";
   60     if [ "$1" = "stop" ]; then exit 0;
   61     else
   62         failure
   63     fi
   64 }
   65 
   66 start()
   67 {
   68     echo -n $"Starting FCoE initiator service: "
   69 
   70     pid=$($FCOEADM -p 2> /dev/null)
   71     if [ -z "$pid" ]; then
   72         modprobe -q libfc
   73         modprobe -q sg
   74         modprobe -q -a $SUPPORTED_DRIVERS
   75 
   76         daemon ${FCOEMON} ${FCOEMON_OPTS}
   77         echo
   78         touch ${LOCKFILE}
   79         echo
   80     else
   81         echo "(already running)"
   82     fi
   83 }
   84 
   85 stop()
   86 {
   87     local force=$1
   88 
   89     pid=$($FCOEADM -p 2> /dev/null)
   90     if [ "$force" == "force" ]
   91     then
   92         action "Destroying any active fcoe interface/s"
   93         [ "$pid" ] && kill -HUP $pid
   94         modprobe -r $SUPPORTED_DRIVERS libfc
   95     else
   96         [ "$pid" ] && kill -TERM $pid
   97     fi
   98 
   99     action $"Stopping FCoE initiator service: "
  100 
  101     rm -f ${LOCKFILE}
  102 }
  103 
  104 status()
  105 {
  106     [ -f ${LOCKFILE} ] || { echo "$FCOEMON is stopped" ; return 3; }
  107 
  108     status=0
  109     pid=$($FCOEADM -p 2> /dev/null)
  110     echo "$FCOEMON is running, pid=$pid"
  111 
  112     interfaces=`$FCOEADM -i 2>&1 | \
  113             awk '/Symbolic Name:/{print $6}' | \
  114             sort | awk '{printf("%s ", $1)}'`
  115 
  116     if [ -z "$interfaces" ]; then
  117         echo "No interfaces created."
  118         status=2
  119     else
  120         echo "Created interfaces: $interfaces"
  121     fi
  122 
  123     return $status
  124 }
  125 
  126 case "$1" in
  127     start)
  128         start
  129         ;;
  130 
  131     stop)
  132         stop $2
  133         ;;
  134 
  135     restart)
  136         stop $2
  137         start
  138         ;;
  139 
  140     force-reload)
  141         stop force
  142         start
  143         ;;
  144 
  145     status)
  146         status
  147         exit $?
  148         ;;
  149     condrestart|try-restart)
  150         status || exit 0
  151         $0 restart
  152         ;;
  153     *)
  154         echo -n "Usage: $0 {start|stop [force]|status|restart [force]|"
  155         echo "force-reload|condrestart|try-restart}"
  156         exit 1
  157         ;;
  158 esac