]> git.entuzijast.net Git - imunes.git/commitdiff
"himage" is used as interface to command vimage(8).
authormiljenko <miljenko>
Thu, 8 Dec 2005 10:29:00 +0000 (10:29 +0000)
committermiljenko <miljenko>
Thu, 8 Dec 2005 10:29:00 +0000 (10:29 +0000)
Options are the same. Hostname is used instead of vimage name.

Usage:
    himage
    himage  vi_hostname [command]
    himage  -m vi_hostname [options]
    himage  -d vi_hostname
    himage  -l [vi_hostname]
    himage  -i vi_hostname interface [target_interface]

Bug found by:
Submitted by:
Requested by:
Reviewed by:
Approved by:
Obtained from:

himage [new file with mode: 0755]

diff --git a/himage b/himage
new file mode 100755 (executable)
index 0000000..9542608
--- /dev/null
+++ b/himage
@@ -0,0 +1,74 @@
+#! /bin/sh 
+
+help() {
+cat <<__END__
+
+Command $0 can be used as interface to command vimage(8).
+Options are the same. Hostname is used instead of vimage name.
+
+Usage:
+    $0
+    $0 vi_hostname [command]
+    $0 -m vi_hostname [options]
+    $0 -d vi_hostname
+    $0 -l [vi_hostname]
+    $0 -i vi_hostname interface [target_interface]
+__END__
+}
+
+vi_name() {
+  all=`vimage -l | grep -v "^ " | tr -d ':"'`
+  for image in $all; do
+    hname=`vimage $image hostname`
+    if test $hname = $1; then
+      if test a$imagename != "a"; then
+        echo "Error: $hname is not a unique name." >&2
+        echo "It is used for nodes $imagename and $image (at least)." >&2
+        exit 1
+      fi
+      imagename=$image
+    fi
+  done
+  if test a$imagename != "a"; then
+    echo $imagename
+  else
+    echo Error: cannot find node named $1 >&2
+    exit 2
+  fi
+}
+
+if test $# -eq 0; then
+    echo -n $(hostname):
+    exec vimage
+elif test $1 = "-h"; then
+    help
+elif test $1 = "-m" || test $1 = "-d" || test $1  =  "-i"; then
+    opt=$1
+    hname=$2
+    shift 2
+    image_name=`vi_name $hname`
+    if [ $? -ne 0 ]; then
+        exit
+    fi
+    exec vimage $opt $image_name $*
+elif test $1 = "-l"; then
+    if test $# -eq 2; then
+        hname=$2
+        image_name=`vi_name $hname`
+        if [ $? -ne 0 ]; then
+           exit
+        fi
+        exec vimage -l $image_name
+    else
+        exec vimage -l
+    fi
+elif test $1 != "-.*"; then
+    hname=$1
+    image_name=`vi_name $hname`
+    if [ $? -ne 0 ]; then
+        exit
+    fi
+    shift 1
+    exec vimage $image_name $*
+fi
+