]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add accurate --hostonly checking for 95iscsi
authorVictor Lowther <victor.lowther@gmail.com>
Sat, 22 Aug 2009 03:11:36 +0000 (22:11 -0500)
committerVictor Lowther <victor.lowther@gmail.com>
Sat, 22 Aug 2009 03:22:40 +0000 (22:22 -0500)
modules.d/95iscsi/check

index 274a49b9559cb2cef691a286b3024bc9d9b44b36..5a47d97bdd89f6c68130eb4ba2038d90f87c5ca8 100755 (executable)
@@ -1,11 +1,35 @@
-#!/bin/sh
+#!/bin/bash
 # We depend on network modules being loaded
 [ "$1" = "-d" ] && echo network
 
+# If our prerequisites are not met, fail anyways.
+which iscsistart hostname iscsi-iname >/dev/null 2>&1 || exit 1
+
 # If hostonly was requested, fail the check if we are not actually
 # booting from root.
-#[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1
 
-# If our prerequisites are not met, fail anyways.
-which iscsistart hostname iscsi-iname >/dev/null 2>&1 || exit 1
+. $dracutfunctions
+
+[[ $debug ]] && set -x
+
+is_iscsi() ( 
+    [[ -L /sys/dev/block/$1 ]] || return
+    cd "$(readlink -f /sys/dev/block/$1)"
+    until [[ -d sys || -d iscsi_session ]]; do
+       cd ..
+    done
+    [[ -d iscsi_session ]]
+)
+
+case $1 in
+    -h) rootdev=$(find_root_block_device)
+       if [[ $rootdev ]]; then
+           # root lives on a block device, so we can be more precise about 
+           # hostonly checking
+           check_block_and_slaves is_iscsi "$rootdev" || exit 1
+       else
+           exit 1
+       fi ;;
+esac
+
 exit 0