summaryrefslogtreecommitdiff
path: root/share/hydra/ssh-config
blob: c30c82fe07234ab77e8caf104cce8de3fc738f16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Thanks to http://paste.debian.net/93242/

# Parameters
NODESDIR=${1}
DOMAIN="`hydra $HYDRA config domain`"

# Syntax check
if [ $# -ne 1 ]; then
  echo "Usage: ${0} nodes_dir"
  exit 1
fi

if [ ! -d ${NODESDIR} ]; then
  echo "Not a directory: ${NODESDIR}"
  exit 1
fi

REGEXP1="\(nodo::vserver::instance\|context\)"
REGEXP2="s/[^\"]*\"//"
REGEXP3="s/\".*//"
REGEXP4="s/[^']*'//"
REGEXP5="s/'.*//"

ishost=1

while read l; do
  if [ ! -z "${ishost}" ]; then
    host=${l}
    unset ishost
  else
    echo Host ${host}.${DOMAIN}
    echo Port 22`printf "%02d" "${l}"`
    echo
    ishost=1
  fi
done < <(grep -R "${REGEXP1}" ${NODESDIR} | sed -e "${REGEXP2}" -e "${REGEXP3}" \
    -e "${REGEXP4}" -e "${REGEXP5}")