5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
28 # Start/stop iscsi initiator service
30 .
/lib
/svc
/share
/smf_include.sh
32 # checkmessage "fsck_device | mount_point"
34 # Simple auxilary routine to the shell function checkfs. Prints out
35 # instructions for a manual file system check before entering the shell.
38 echo "" > /dev
/console
39 if [ "$1" != "" ] ; then
40 echo "WARNING - Unable to repair one or more \c" \
42 echo "of the following filesystem(s):" > /dev
/console
43 echo "\t$1" > /dev
/console
45 echo "WARNING - Unable to repair one or more filesystems." \
48 echo "Run fsck manually (fsck filesystem...)." > /dev
/console
49 echo "" > /dev
/console
53 # checkfs raw_device fstype mountpoint
55 # Check the file system specified. The return codes from fsck have the
57 # 0 - file system is unmounted and okay
58 # 32 - file system is unmounted and needs checking (fsck -m only)
59 # 33 - file system is already mounted
60 # 34 - cannot stat device
61 # 36 - uncorrectable errors detected - terminate normally (4.1 code 8)
62 # 37 - a signal was caught during processing (4.1 exit 12)
63 # 39 - uncorrectable errors detected - terminate rightaway (4.1 code 8)
64 # 40 - for root, same as 0 (used by rcS to remount root)
67 /usr
/sbin
/fsck
-F $2 -m $1 >/dev
/null
2>&1
71 # Determine fsck options by file system type
79 echo "The "$3" file system ("$1") is being checked."
80 /usr
/sbin
/fsck
-F $2 ${foptions} $1
83 0|
40) # file system OK
86 *) # couldn't fix the file system
87 echo "/usr/sbin/fsck failed with exit code "$?
"."
99 while read special fsckdev mountp fstype fsckpass automnt mntopts
; do
101 '#'* |
'' ) # Ignore comments, empty lines.
104 '-') # Ignore "no-action" lines.
108 if [ "$automnt" != "iscsi" ]; then
111 if [ "$fstype" = "-" ]; then
112 echo "iscsi-initiator: FSType of iscsi LUN \c" 1>&2
113 echo "$special cannot be identified" 1>&2
118 # Ignore entries already mounted
120 /usr
/bin
/grep " $mountp " /etc
/mnttab
>/dev
/null \
124 # Can't fsck if no fsckdev is specified
126 if [ "$fsckdev" = "-" ]; then
127 iscsilist
="$iscsilist $mountp"
132 # fsck everything else:
134 # fsck -m simply returns true if the filesystem is
135 # suitable for mounting.
137 /usr
/sbin
/fsck
-m -F $fstype $fsckdev >/dev
/null
2>&1
139 0|
40) iscsilist
="$iscsilist $mountp"
142 32) checkfs
$fsckdev $fstype $mountp
143 iscsilist
="$iscsilist $mountp"
146 33) # already mounted
147 echo "$special already mounted"
149 34) # bogus special device
150 echo "Cannot stat $fsckdev - ignoring"
153 *) # uncorrectable errors
154 echo "$fsckdev uncorrectable error"
160 [ -z "$iscsilist" ] ||
/sbin
/mount
-a $iscsilist
161 for iscsilun
in $iscsilist
163 /usr
/bin
/grep " $iscsilun " /etc
/mnttab
>/dev
/null
2>&1
164 if [ $?
-ne 0 ]; then
165 echo "Fail to mount $iscsilun"
174 # Generate iscsi mountp list from /etc/vfstab
176 while read special fsckdev mountp fstype fsckpass automnt mntopts
; do
178 '#'* |
'') continue;; # Ignore comments,
180 '-') continue;; # Ignore "no-action lines.
182 if [ "$automnt" != "iscsi" ]; then
185 /usr
/bin
/grep " $mountp " /etc
/mnttab
>/dev
/null
2>&1
186 if [ $?
-ne 0 ]; then
189 iscsilist
="$iscsilist $mountp"
192 if [ -n "$iscsilist" ]; then
193 umount
-a $iscsilist 1>&2
203 /usr
/bin
/pgrep
-P 1 -x iscsid
204 if [ $?
-ne 0 ]; then
205 /lib
/svc
/method
/iscsid
207 if [ $?
-eq 0 ]; then
209 while [ $delay -gt 0 ]; do
210 delay
=`expr $delay - 1`
212 if [ $?
-eq 1 ]; then
213 if [ $delay -gt 0 ]; then
217 echo "iscsi-initiator: mount iscsi \c"
218 echo "lun in /etc/vfstab fail."
220 exit $SMF_EXIT_ERR_CONFIG
233 /usr
/bin
/pkill
-P 1 -x iscsid
238 echo "Usage: $0 { start | stop }"