Changeset 133


Ignore:
Timestamp:
Dec 28, 2017, 10:45:56 AM (7 years ago)
Author:
g7moreau
Message:
  • Better comment, better verbose
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tssh/tssh

    r132 r133  
    122122      fi
    123123
    124       cluster=$(grep "^${host#*@}\b" ${HOME}/.csshrc | cut -f 2 -d '=')
     124      # short host without login part if any
     125      justhost=${host#*@}
     126     
     127      cluster=$(grep "^${justhost}\b" ${HOME}/.csshrc | cut -f 2 -d '=')
    125128      if [ "${cluster}" == "" ]
    126129      then
     130         # just a host to scan and add
    127131         if [ "${fast}" != 'yes' ]
    128132         then
    129             # short host without login part if any
    130             if host ${host#*@} | grep -q 'not found'
     133            # test if exists host
     134            if host ${justhost} | grep -q 'not found'
    131135            then
    132                [ "${verbose}" == "yes" ] && echo Warning: ${host#*@} does not exists
     136               [ "${verbose}" == 'yes' ] && echo Warning: ${justhost} does not exists
    133137               continue
    134138            fi
    135             if ! nmap -p 22 -sT -PN ${host#*@} | grep -q '\bopen\b'
     139            if ! nmap -p 22 -sT -PN ${justhost} | grep -q '\bopen\b'
    136140            then
    137                if host ${host#*@}.${dyn_domain} | grep -q 'not found' || ! nmap -p 22 -sT -PN ${host#*@}.${dyn_domain} | grep -q '\bopen\b'
     141               if host ${justhost}.${dyn_domain} | grep -q 'not found' || ! nmap -p 22 -sT -PN ${justhost}.${dyn_domain} | grep -q '\bopen\b'
    138142               then
    139                   [ "${verbose}" == "yes" ] && echo Warning: ${host#*@} is down
     143                  [ "${verbose}" == 'yes' ] && echo Warning: ${justhost} is down
    140144                  continue
    141145               else
    142                   host=${host#*@}.${dyn_domain}
    143                   ssh-keygen -q -R $(LANG=C host ${host#*@} | awk '{print $4}')
     146                  [ "${verbose}" == 'yes' ] && echo Warning: remove ssh key of ${justhost}.${dyn_domain}
     147                  host=${justhost}.${dyn_domain}
     148                  ssh-keygen -q -R $(LANG=C host ${justhost} | awk '{print $4}')
    144149               fi
    145150            fi
    146151         fi
     152         [ "${verbose}" == 'yes' ] && echo Warning: add ${host} on list with mode ${mode}
    147153         echo "${host}" >> "/tmp/${base_path}/master${mode}"
    148154      else
     155         # cluster, jump in a recursive mode
     156         [ "${verbose}" == 'yes' ] && echo Warning: recursive mode for cluster ${cluster} with mode ${mode}
    149157         cluster=$(get_host_list "${cluster}${mode}")
    150158      fi
Note: See TracChangeset for help on using the changeset viewer.