File: initd.fedora

package info (click to toggle)
fcoe-utils 1.0.34-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,040 kB
  • sloc: ansic: 12,049; sh: 1,302; makefile: 80
file content (158 lines) | stat: -rwxr-xr-x 3,027 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# Copyright(c) 2010-2011 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.
#
# chkconfig: - 21 80
#
# Maintained at www.Open-FCoE.org

### BEGIN INIT INFO
# Provides: fcoe
# Required-Start: network
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Open-FCoE Initiator
# Description: Open-FCoE Initiator
### END INIT INFO

CONFIG_DIR=/etc/fcoe
LOG_FILE="/var/log/fcoemon.log"
LOCKFILE="/var/lock/subsys/fcoe"
FCOEMON=/usr/sbin/fcoemon
FCOEADM=/usr/sbin/fcoeadm
FCOEMON_OPTS=

. /etc/init.d/functions
. $CONFIG_DIR/config

if [ "$USE_SYSLOG" = "yes" ] || [ "$USE_SYSLOG" = "YES" ]; then
    FCOEMON_OPTS+=" --syslog=yes"
fi

if [ "$DEBUG" = "yes" ] || [ "$DEBUG" = "YES" ]; then
    FCOEMON_OPTS+=" --debug"
fi

test -x $FCOEADM || {
	echo "$FCOEADM not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else
	    failure
	fi
}

test -x $FCOEMON || {
	echo "$FCOEMON not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else
	    failure
	fi
}

start()
{
	echo -n $"Starting FCoE initiator service: "

	pid=$($FCOEADM -p 2> /dev/null)
	if [ -z "$pid" ]; then
		modprobe -q libfc
		modprobe -q sg
		modprobe -q -a $SUPPORTED_DRIVERS

		daemon ${FCOEMON} ${FCOEMON_OPTS}
		echo
		touch ${LOCKFILE}
		echo
	else
		echo "(already running)"
	fi
}

stop()
{
	local force=$1

	pid=$($FCOEADM -p 2> /dev/null)
	if [ "$force" == "force" ]
	then
		action "Destroying any active fcoe interface/s"
		[ "$pid" ] && kill -HUP $pid
		modprobe -r $SUPPORTED_DRIVERS libfc
	else
		[ "$pid" ] && kill -TERM $pid
	fi

	action $"Stopping FCoE initiator service: "

	rm -f ${LOCKFILE}
}

status()
{
	[ -f ${LOCKFILE} ] || { echo "$FCOEMON is stopped" ; return 3; }

	status=0
	pid=$($FCOEADM -p 2> /dev/null)
	echo "$FCOEMON is running, pid=$pid"

	interfaces=`$FCOEADM -i 2>&1 | \
		    awk '/Symbolic Name:/{print $6}' | \
		    sort | awk '{printf("%s ", $1)}'`

	if [ -z "$interfaces" ]; then
		echo "No interfaces created."
		status=2
	else
		echo "Created interfaces: $interfaces"
	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