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

Make pelegant_setup.sh script working

parent 5e04c99c
#!/bin/bash #!/bin/bash
# bash >= 4 required # bash >= 4 required
# This script assumes to be run only once per day and overwrites files # 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 # Search the "Edit"-line
# #
# - This script has not been tested so far # - This script has not been tested so far
...@@ -11,22 +11,39 @@ IFS=$'\n\t' ...@@ -11,22 +11,39 @@ IFS=$'\n\t'
############################################################ ############################################################
# Edit: # 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)" # main_host=$(hostname -f)
ssh-keygen -f "${filename}" -q 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 if [ -f ~/.mpihosts ]; then
mv ~/.mpihosts ~/.mpihosts.${date --iso} /usr/bin/mv ~/.mpihosts ~/.mpihosts.$(date --iso)
fi fi
for cpus in "${!host_cpus[@]}"; do for host in "${!host_cpus[@]}"; do
echo "${host_cpus[$cpus]}":${cpus} user=${USER} >> ~/.mpihosts /usr/bin/echo "${host}:${host_cpus[$host]}" user=${USER} >> ~/.mpihosts
done done
for cpus in "${!host_cpus[@]}"; do printf "Copying files and mounting SSHFS\n"
dest="${host_cpus[$cpus]}" for host in "${!host_cpus[@]}"; do
ssh-copy-id -i "${filename}" ${dest} cpu="${host_cpus[$host]}"
scp "${filename}" "${dest}:~/.ssh/" printf "SSH copy from %s to %s (%s)", ${main_host}, ${host}, ${filename}
scp "${mpifile}" "${dest}:.mpihosts" 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 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