-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_ssh.recipe
More file actions
55 lines (46 loc) · 1.31 KB
/
client_ssh.recipe
File metadata and controls
55 lines (46 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
BootStrap: docker
From: centos:7.3.1611
%labels
author "[email protected]"
version "0.4"
%setup
EXIT=0
for item in client_ssh.slurm_id_rsa; do
if [ ! -f $item ]; then
echo "file $file doesn't exists. It's mandatory. Please create the key."
EXIT=1
fi
done
[ $EXIT -ne 0 ] && exit 1
mkdir -p $SINGULARITY_ROOTFS/usr/local/etc/ssh/slurm
cp client_ssh.slurm_id_rsa $SINGULARITY_ROOTFS/usr/local/etc/ssh/slurm/id_rsa
chmod 644 $SINGULARITY_ROOTFS/usr/local/etc/ssh/slurm/id_rsa
%help
Just a ssh client
%post
yum -y install openssh-clients
# slurm proxy
cat <<EOF >> /usr/local/bin/slurm_proxy
SSH_USER=user_account
SSH_HOST=server_account
run_remote_command() {
ssh -o "StrictHostKeyChecking no" -i /usr/local/etc/ssh/slurm/id_rsa \$SSH_USER@\$SSH_HOST \$@
}
EOF
# slurm squeue
cat <<EOF >> /usr/local/bin/squeue
#!/bin/bash
source /usr/local/bin/slurm_proxy
run_remote_command squeue \$@
EOF
chmod 755 /usr/local/bin/squeue
# slurm sbatch
cat <<EOF >> /usr/local/bin/sbatch
#!/bin/bash
source /usr/local/bin/slurm_proxy
[ ! -f \$1 ] && echo "cannot access to file '\$1'" && exit 1
scp -o "StrictHostKeyChecking no" -i /usr/local/etc/ssh/slurm/id_rsa \$1 \$SSH_USER@\$SSH_HOST:~
run_remote_command sbatch \$@
run_remote_command rm -v \$1
EOF
chmod 755 /usr/local/bin/sbatch