]> git.entuzijast.net Git - imunes.git/commitdiff
Support for the new directory structure: /tmp/$eid/$node.
authormiljenko <miljenko>
Mon, 3 Dec 2007 15:13:06 +0000 (15:13 +0000)
committermiljenko <miljenko>
Mon, 3 Dec 2007 15:13:06 +0000 (15:13 +0000)
Added options to return eid (-e) and node (-n).

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

himage

diff --git a/himage b/himage
index d66ac580e81240184b0e3e6d0cef572e36aa95d4..9ddbf1fc8079644c6c7758e4c5ab9d2e63690504 100755 (executable)
--- a/himage
+++ b/himage
@@ -4,14 +4,17 @@ 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.
+Options are (mainly) 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 -l [vi_hostname]   ---> list
+    $0 -v vi_hostname     ---> vimage name 
+    $0 -n vi_hostname     ---> vimage node name
+    $0 -e vi_hostname     ---> vimage eid name 
     $0 -i vi_hostname interface [target_interface]
 __END__
 }
@@ -20,8 +23,8 @@ vi_name() {
   all=`vimage -lr | grep -v "^ " | tr -d ':"' | grep -v '^\.$' | grep "\." ` 
   for image in $all; do
     hname=`vimage $image hostname`
-    if test $hname = $1; then
-      if test a$imagename != "a"; then
+    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
@@ -29,7 +32,7 @@ vi_name() {
       imagename=$image
     fi
   done
-  if test a$imagename != "a"; then
+  if test "a$imagename" != "a"; then
     echo $imagename
   else
     echo Error: cannot find node named $1 >&2
@@ -42,6 +45,31 @@ if test $# -eq 0; then
     exec vimage
 elif test $1 = "-h"; then
     help
+elif test $1 = "-v"; then
+    hname=$2
+    image_name=`vi_name $hname`
+    if test $? -ne 0 ;then
+        exit 2
+    fi
+    echo $image_name
+    exit
+elif test $1 = "-e"; then
+    hname=$2
+    image_name=`vi_name $hname`
+    if test $? -ne 0 ;then
+        exit 2
+    fi
+    # echo $image_name | sed 's/\.[^\.][^\.]*$//'
+    echo $image_name | awk -F"." '{n=NF-1; print $n}'
+    exit
+elif test $1 = "-n"; then
+    hname=$2
+    image_name=`vi_name $hname`
+    if test $? -ne 0 ;then
+        exit 2
+    fi
+    echo $image_name | awk -F"." '{print $NF}'
+    exit
 elif test $1 = "-m" || test $1 = "-d" || test $1  =  "-i"; then
     opt=$1
     hname=$2