-
Notifications
You must be signed in to change notification settings - Fork 1
/
cleanflipdirection.sh
executable file
·51 lines (39 loc) · 1.36 KB
/
cleanflipdirection.sh
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
infile=$1
outfile=$2
infile_host=$(realpath "${infile}")
outfile_host=$(realpath "${outfile}")
# Test that file and folder exists, all of these will always get mounted
if [ ! -f $infile_host ]; then
>&2 echo "infile doesn't exist"
exit 1
fi
# All paths we see will start from the project root, even if the command is called from somewhere else
project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${project_dir}/scripts/init-containerization.sh"
mount_flags=$(format_mount_flags "-B")
# indir
indir_host=$(dirname "${infile_host}")
infile_name=$(basename "${infile_host}")
indir_container="/cleansumstats/input"
infile_container="${indir_container}/${infile_name}"
# outdir
outdir_host=$(dirname "${outfile_host}")
outfile_name=$(basename "${outfile_host}")
outdir_container="/cleansumstats/outdir"
outfile_container="${outdir_container}/${outfile_name}"
FAKE_HOME="tmp/fake-home"
export SINGULARITY_HOME="/cleansumstats/${FAKE_HOME}"
mkdir -p "${FAKE_HOME}"
#echo "${infile_container}"
#echo "${outfile_container}"
exec singularity run \
--contain \
--cleanenv \
${mount_flags} \
-B "${indir_host}:${indir_container}" \
-B "${outdir_host}:${outdir_container}" \
-B "/tmp:/tmp" \
"tmp/${singularity_image_tag}" \
/cleansumstats/bin/flip_direction_on_clean.sh \
"${infile_container}" \
"${outfile_container}"