Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
las-it-organisation
32-0-IT instructions and rules
ansible
Commits
de1f88fa
Commit
de1f88fa
authored
Feb 05, 2018
by
julian.gethmann
Browse files
Make pelegant_setup.sh script working
parent
5e04c99c
Changes
1
Hide whitespace changes
Inline
Side-by-side
roles/elegant/files/pelegant_setup.sh
View file @
de1f88fa
#!/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
host
s
_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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment