-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_mod
executable file
·63 lines (53 loc) · 1.78 KB
/
make_mod
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
55
56
57
58
59
60
61
62
63
#! /bin/bash
set -e
# Read in parameters
config=$1
set -o allexport
source $config
installation_dir=/share/ClusterShare/software/contrib/johree/img2mod
set +o allexport
# Report config values
echo "Image cache:" $image_cache
echo "Image: " $image
echo "Tag: " $tag
echo "Command: " $command
echo "Reference: " $reference
# Create directories
command_path=${image_cache}/wrappers/${command}/${tag}
mkdir -p $command_path
mkdir -p $command_path/fakehome
# Copy wrapper script template and prepare for editing
cp $installation_dir/wrapper.template $command_path/$command
cd $command_path
echo "Creating wrapper for $command at $command_path"
# Replace fields with variables
sed -i "s|CACHE|$image_cache|g" $command
sed -i "s|IMAGE|$image|g" $command
sed -i "s|TAG|$tag|g" $command
sed -i "s|COMMAND|$command|g" $command
# Make wrapper executable
chmod +x $command
echo "Wrapper created"
# Copy modulefile template and prepare for editing
module_path=/share/ClusterShare/Modules/modulefiles/contrib/centos7.8/${USER}/${command}
cd $image_cache
mkdir -p $module_path
cp $installation_dir/modulefile.template $module_path/$tag
cd $module_path
echo "Creating modulefile for $command version $tag at $module_path"
# Replace fields with variables
sed -i "s|CACHE|$image_cache|g" $tag
sed -i "s|COMMAND|$command|g" $tag
sed -i "s|TAG|$tag|g" $tag
sed -i "s|USER|$USER|g" $tag
sed -i "s|REFERENCE|$reference|g" $tag
echo "Modulefile created"
# Download docker image and convert to singularity format (SIF)
# Computationally intensive, so submit as a job
cd $installation_dir
qsub make_mod.sge
echo "It may take a few minutes to download and convert the Singularity image"
echo "You will receive an email notification when it is ready"
echo
echo "Load the module as follows: "
echo "module load ${USER}/${command}/${tag}"