Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docker2singularity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,15 @@ if [[ $WORKINGDIR != '""' ]]; then
fi

# First preference goes to both entrypoint / cmd, then individual
if [ -n "$ENTRYPOINT" ] && [ -n "$CMD" ]; then
echo exec "$ENTRYPOINT" "$CMD" '"$@"' >> $build_sandbox/.singularity.d/runscript;
if [ -n "$CMD" ]; then
echo 'if [ $# = 0 ]; then' >> $build_sandbox/.singularity.d/runscript
# Only add the entrypoint if it's not null
echo \ \ exec ${ENTRYPOINT:+"$ENTRYPOINT"} "$CMD" >> $build_sandbox/.singularity.d/runscript;
echo "else" >> $build_sandbox/.singularity.d/runscript
echo \ \ exec ${ENTRYPOINT:+"$ENTRYPOINT"} '"$@"' >> $build_sandbox/.singularity.d/runscript;
echo "fi" >> $build_sandbox/.singularity.d/runscript
elif [ -n "$ENTRYPOINT" ]; then
echo exec "$ENTRYPOINT" '"$@"' >> $build_sandbox/.singularity.d/runscript;
elif [ -n "$CMD" ]; then
echo exec "$CMD" '"$@"' >> $build_sandbox/.singularity.d/runscript;
fi

chmod +x $build_sandbox/.singularity.d/runscript;
Expand Down