sshpc_client_pair.sh
por EDSON - LAMBDA
—
última modificação
13/06/2023 11h31
sshpc_client_pair.sh — 2 KB
Conteúdo do arquivo
#!/bin/bash ######################################################################################### ## SSHPC - Cluster de processamento distribuído baseado em SSH ## ## ## ## Local: Laboratório Multiusuário de Bioinformática e Análise de Dados (LAMBDA) ## ## Centro de Biotecnologia (CBiotec), Universidade Federal da Paraíba (UFPB) ## ## Data: 30/05/2023 ## ## Coordenador: Edson Luiz Folador ## ## IC: Arthur Araújo de Lacerda ## ######################################################################################### readonly PROGNAME=$(basename "$0") readonly PROGDIR=$(readlink -m $(dirname "$0")) readonly SSHPC_DIRECTORY="/home/sshpc" debugging() { ${debug} && echo -e "$1"; } pair() { ### Checks if installation and connection are successful source ${SSHPC_DIRECTORY}/.bin/sshpc.conf while true do ssh -p ${port} -o StrictHostKeyChecking=no -o PasswordAuthentication=no sc_pair_sshpc_${lab}_${mac}@${server} if test -f "${SSHPC_DIRECTORY}/id_rsa.pub"; then cat "${SSHPC_DIRECTORY}/id_rsa.pub" > "${SSHPC_DIRECTORY}/.ssh/authorized_keys" rm "${SSHPC_DIRECTORY}/id_rsa.pub" debugging "connection successful" return 0 else debugging "still not connected" sleep 5 fi done } update_config_file() { ### Checks for the config file local server="${1}" local lab="${2}" [[ -n $server ]] && sed -i "${SSHPC_DIRECTORY}/.bin/sshpc.conf" -e "s/server=.*/server=${server}/" [[ -n $lab ]] && sed -i "${SSHPC_DIRECTORY}/.bin/sshpc.conf" -e "s/lab=.*/lab=${lab}/" echo "${SSHPC_DIRECTORY}/.bin/sshpc.conf" } main() { local debug=true while true; do case "$1" in -q | --quiet) debug=false; shift;; -i | --ip) local server=${2}; shift; shift;; -l | --lab) local lab=${2}; shift; shift;; --) break;; *) break ;; esac done update_config_file "${server}" "${lab}" pair } main "$@"