Commit de1f88fa authored by julian.gethmann's avatar julian.gethmann

Make pelegant_setup.sh script working

parent 5e04c99c
#!/bin/bash
# bash >= 4 required
# This script assumes to be run only once per day and overwrites files
# It also does shouldn't be run for different hosts in parallel
# It also shouldn't be run for different hosts in parallel
# Search the "Edit"-line
#
# - This script has not been tested so far
......@@ -11,22 +11,39 @@ IFS=$'\n\t'
############################################################
# Edit:
declare -A hosts_cpus=( ["las113"]="6" ["las126"]="11" )
declare -A host_cpus=( ["129.13.108.79"]="3" ["129.13.108.113"]="6" )
############################################################
filename="~/.ssh/Pelegant_$(date --iso)"
ssh-keygen -f "${filename}" -q
# main_host=$(hostname -f)
main_host=$(ip -br -4 addr|\
grep '129.13.108.'|\
awk '{print $3}'|\
cut -d"/" -f1)
printf "Generating SSH keys\n"
filename=~/.ssh/"id_Pelegant_$(date --iso)"
ssh-keygen -q -t ed25519 -o -f "${filename}" -C "Pelegant run from ${main_host} at $(date)"
printf "Creating mpihosts file\n"
if [ -f ~/.mpihosts ]; then
mv ~/.mpihosts ~/.mpihosts.${date --iso}
/usr/bin/mv ~/.mpihosts ~/.mpihosts.$(date --iso)
fi
for cpus in "${!host_cpus[@]}"; do
echo "${host_cpus[$cpus]}":${cpus} user=${USER} >> ~/.mpihosts
for host in "${!host_cpus[@]}"; do
/usr/bin/echo "${host}:${host_cpus[$host]}" user=${USER} >> ~/.mpihosts
done
for cpus in "${!host_cpus[@]}"; do
dest="${host_cpus[$cpus]}"
ssh-copy-id -i "${filename}" ${dest}
scp "${filename}" "${dest}:~/.ssh/"
scp "${mpifile}" "${dest}:.mpihosts"
printf "Copying files and mounting SSHFS\n"
for host in "${!host_cpus[@]}"; do
cpu="${host_cpus[$host]}"
printf "SSH copy from %s to %s (%s)", ${main_host}, ${host}, ${filename}
scp "${filename}" "${host}:~/.ssh/"
scp "${filename}.pub" "${host}:~/.ssh/"
ssh-copy-id -i "${filename}" ${host}
ssh-copy-id -i "${filename}" ${main_host}
scp ~/.mpihosts "${host}:.mpihosts"
curdir=${PWD}
ssh -i "${filename}" ${host} "ssh-copy-id -i ${filename} ${main_host}"
ssh -i "${filename}" ${host} "mkdir ${curdir} && sshfs ${main_host}:${curdir} ${curdir} -o IdentityFile=\"${filename}\""
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment