#!/bin/sh
#set -x
RES_COL=40
MOVE_TO_COL="echo -en \\033[${RES_COL}G"
SETCOLOR_SUCCESS="echo -en \\033[1;32m"
SETCOLOR_FAILURE="echo -en \\033[1;31m"
SETCOLOR_WARNING="echo -en \\033[1;33m"
SETCOLOR_NORMAL="echo -en \\033[0;39m"

echo_success() {
  $MOVE_TO_COL
  echo -n "[  "
  $SETCOLOR_SUCCESS
  echo -n $1
  $SETCOLOR_NORMAL
  echo "  ]"
}

echo_failure() {
  $MOVE_TO_COL
  echo -n "[  "
  $SETCOLOR_FAILURE
  echo -n $1
  $SETCOLOR_NORMAL
  echo "  ]"
}

function test_vo {
   local voname="$1"
   local port=`cat $GLITE_LOCATION/etc/voms/$voname/voms.conf  | grep '^--port' | sed 's/^--port=//'`
   local dn=`openssl x509 -subject -noout -in /etc/grid-security/hostcert.pem|cut -d' ' -f2-`
   set -e
   if nc localhost $port < /dev/null; then
       :
   else
       echo_failure Core
       return 1
   fi
   set +e
   cat >/tmp/vomses <<EOF
"$voname" "localhost" "$port" "$dn" "$voname"
EOF
   rm -f /tmp/oo
   /opt/glite/bin/voms-proxy-init --voms $vo --userconf=/tmp/vomses 2>/tmp/oo >/dev/null
   res=$?
   if test $res -ne 0; then
      grep "User unknown to this VO" /tmp/oo >/dev/null
      res=$?
      if test $res -ne 0; then
      echo_failure Core
      return 1
      fi
   fi
   set -e
   if [ `voms-admin --vo $voname list-roles 2>&1 >/dev/null | wc -l` -gt 0 ]; then 
       echo_failure Admin
       return 1
   fi
   echo_success OK
   return 0
}

vos=            # Space-separated list of VOs
function get_vos {
    if [ -d "${GLITE_LOCATION_VAR}/etc/voms-admin" ]; then
        for d in "${GLITE_LOCATION_VAR}"/etc/voms-admin/*; do
       if [ -r "$d/voms.database.properties" ]; then
      vos="$vos `basename $d`"
       fi
   done
   all_vos=yes
    else 
        echo "It seems you don't have any VOs configured yet."
        exit 1
    fi
}


get_vos;

result=0

for vo in $vos; do
    echo -n "Testing $vo: "

    if test_vo $vo; then
   :
    else
   result=1
    fi
done

exit $result
-- Main.vciaschi - 16 Mar 2006
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2006-03-23 - MariaDimou
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LCG All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback