+split_hostname () {
+ local name=$1
+ case $name in
+ *:*) host=`echo $name | sed 's/:.*$//'`
+ name=`echo $name | sed 's/[^:]*://'`
+ ;;
+ *) host=localhost
+ ;;
+ esac
+ echo "$host $name"
+}
+
+DSH=${DSH:-"ssh"}
+
+dsh () {
+ local node="$1"
+ local user="$2"
+ shift 2
+ local command="$@"
+
+ command="export PATH=/sbin:/usr/sbin:\$PATH; $command"
+
+ case $DSH in
+ ssh)
+ if [ -n "$user" ]; then
+ user="$user@"
+ fi
+ $DSH $user$node "$command"
+ ;;
+ rsh)
+ if [ -n "$user" ]; then
+ user="-l $user"
+ fi
+ $DSH $user $node "$command"
+ ;;
+ esac
+}
+
+# how to run commands on other nodes
+remote_shell () {
+ local host=$1
+ shift
+ local cmds="$@"
+ if [ "$host" = "localhost" -o "$host" = `uname -n` ]; then
+ eval "$cmds"
+ else
+ # split $host into $host and $user
+ local user=""
+ if [[ $host == *@* ]]; then
+ user=${host%@*}
+ host=${host#*@}
+ fi
+ dsh $host "$user" "$cmds"
+ fi
+}
+
+
+# check either scsidevs or rawdevs is specified
+# but only one of them
+if [ -n "$scsidevs" -a -n "$rawdevs" -o -z "$scsidevs$rawdevs" ]; then
+ echo "Must either specify scsidevs or rawdevs"
+ exit 1
+fi
+
+# retrieve host and device if specified as "hostname:device"
+ndevs=0