~ubuntu-branches/ubuntu/wily/fcoe-utils/wily

« back to all changes in this revision

Viewing changes to etc/initd/initd.fcoe

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-02-16 14:46:23 UTC
  • Revision ID: james.westby@ubuntu.com-20100216144623-n6gqxpxc5nvonv9f
Tags: upstream-1.0.9
ImportĀ upstreamĀ versionĀ 1.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Copyright(c) 2009 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
# Maintained at www.Open-FCoE.org
 
19
#
 
20
#
 
21
# chkconfig: 2345 92 19
 
22
# description: OpenFC and FCoE: Fibre Channel over Ethernet SAN setup
 
23
 
 
24
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
25
 
 
26
HBA=
 
27
FCOEADM=fcoeadm
 
28
FCOE_CONF=/etc/fcoe/open-fcoe.conf
 
29
 
 
30
# validates the ifname
 
31
fcoe_gethba() {
 
32
        HBA=
 
33
        if [ ! -e $FCOE_CONF ]
 
34
        then
 
35
                echo "Open-fcoe config file $FCOE_CONF not found!"
 
36
                return
 
37
        fi
 
38
        # get HBA=
 
39
        HBA=`grep -v "#" $FCOE_CONF | grep "HBA=" | cut -f2 -d=`
 
40
        if ! ifconfig $HBA &> /dev/null
 
41
        then
 
42
                echo "HBA $HBA not found in $FCOE_CONF!"
 
43
                HBA=
 
44
        fi
 
45
}
 
46
# check fcoeadm
 
47
which $FCOEADM > /dev/null 2>&1
 
48
if [ "$?" -eq "1" ]
 
49
then
 
50
        echo "$0: $FCOEADM command not installed" >&2
 
51
        exit 1
 
52
fi
 
53
 
 
54
# Switch on start / stop argument
 
55
case "$1" in
 
56
start)
 
57
 
 
58
        # start fcmon
 
59
        lsmod | grep fcoe &> /dev/null
 
60
        if [ "$?" -eq "1" ]
 
61
        then
 
62
                modprobe -q fcoe 2> /dev/null
 
63
                if [ "$?" -eq "1" ]
 
64
                then
 
65
                        echo "Failed to load FCoE driver module!"
 
66
                        exit 1
 
67
                fi
 
68
        fi
 
69
        # get HBA from conf
 
70
        fcoe_gethba
 
71
        if [ -z "$HBA" ]
 
72
        then
 
73
                echo "Please setup the config file $FCOE_CONF first!"
 
74
                exit 1
 
75
        else
 
76
                $FCOEADM --create $HBA >&2
 
77
        fi
 
78
        ;;
 
79
 
 
80
stop)
 
81
        lsmod | grep fcoe &> /dev/null
 
82
        if [ "$?" -eq "1" ]
 
83
        then
 
84
                echo "Open-FCoE driver module not loaded!"
 
85
                exit 1
 
86
        fi
 
87
        fcoe_gethba
 
88
        if [ -n "$HBA" ]
 
89
        then
 
90
                $FCOEADM --destroy $HBA >&2
 
91
        fi
 
92
        ;;
 
93
 
 
94
status)
 
95
        lsmod | grep fcoe &> /dev/null
 
96
        if [ "$?" -eq "1" ]
 
97
        then
 
98
                echo "Open-FCoE driver module not loaded!"
 
99
                exit 1
 
100
        fi
 
101
        fcoe_gethba
 
102
        $FCOEADM --query $HBA >&2
 
103
        ;;
 
104
 
 
105
restart | reload)
 
106
        $0 stop
 
107
        $0 start
 
108
        ;;
 
109
 
 
110
save)
 
111
        ;;
 
112
 
 
113
*)
 
114
        echo "Usage: $0 {start|stop|reload|restart|status}" >&2
 
115
        exit 1
 
116
        ;;
 
117
esac