Skip to content

Commit

Permalink
Merge pull request #76 from kjsanger/devel
Browse files Browse the repository at this point in the history
Fix singularity-wrapper script
  • Loading branch information
kjsanger authored Oct 3, 2023
2 parents 21ea264 + ede1c1d commit 73ba6dd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions singularity/scripts/singularity-wrapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (C) 2023 Genome Research Ltd. All rights reserved.
#
Expand All @@ -17,7 +17,7 @@
#
# Author: Keith James <kdj@sanger.ac.uk>

# set -euo pipefail ## FIXME: bashism
set -euo pipefail

usage() {
cat 1>&2 << EOF
Expand All @@ -36,7 +36,7 @@ Usage: $0
[-e]
[-h]
[-i <Docker image name>]
[-m <manifest path>]
[-m <JSON manifest path>]
[-p <wrapper install prefix>]
[-r <Docker registry name>]
[-s]
Expand Down Expand Up @@ -73,7 +73,7 @@ EOF

# Print an application manifest
print_manifest() {
cat "$MANIFEST_PATH"
jq . "$MANIFEST_PATH"
}

# Write a bash script wrapping an application in a Docker container
Expand Down Expand Up @@ -113,9 +113,9 @@ install_wrappers() {
install -d "$dir"
cp "/usr/local/bin/$singularity_wrap_impl" "$PREFIX/bin"

while IFS= read -r exe; do
for exe in "${wrappers[@]}" ; do
write_wrapper "$dir" "$exe"
done < "$MANIFEST_PATH"
done
}

DOCKER_REGISTRY=${DOCKER_REGISTRY:-ghcr.io}
Expand All @@ -124,7 +124,7 @@ DOCKER_IMAGE=${DOCKER_IMAGE:-""}
DOCKER_TAG=${DOCKER_TAG:-latest}

PREFIX=${PREFIX:-/opt/wtsi-npg}
MANIFEST_PATH=${MANIFEST_PATH:-"$PREFIX/etc/manifest.txt"}
MANIFEST_PATH=${MANIFEST_PATH:-"$PREFIX/etc/manifest.json"}

singularity_wrap_impl="singularity-run-docker"

Expand Down Expand Up @@ -171,11 +171,18 @@ done

shift $((OPTIND -1))

declare -a wrappers
if [ ! -e "$MANIFEST_PATH" ] ; then
echo -e "\nERROR:\n The manifest of executables at '$MANIFEST_PATH' does not exist"
exit 4
fi





wrappers=($(jq -j '.executable[] + " "' "$MANIFEST_PATH"))

operation="$@"
if [ -z "$operation" ] ; then
usage
Expand Down

0 comments on commit 73ba6dd

Please sign in to comment.