Skip to content

Commit

Permalink
Support running multiple commands sequentially
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Mar 21, 2024
1 parent b627e97 commit 86800cd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash -e

show_help() {
echo -e "\nUsage: $0 [OPTIONS] <command>\n"
echo -e "\nUsage: $0 [OPTIONS] <commands>\n"
echo "Options:"
echo " --download-src The source file or folder to download"
echo " --download-dest The destination file or folder to download to"
echo " --upload-src The source file or folder to upload"
echo " --upload-dest The destination file or folder to upload to"
echo -e "\nThis script downloads the necessary files, executes the specified command, and then uploads the output files.\n"
echo -e "\nThis script downloads the necessary files, executes the specified commands, and then uploads the output files.\n"
}

resolve_path() {
Expand Down Expand Up @@ -55,8 +55,8 @@ done

set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters

if [ "$#" -ne 1 ]; then
echo "Error: Incorrect number of arguments. Expected 1, got $#."
if [ "$#" -lt 1 ]; then
echo "Error: Incorrect number of arguments. Expected more than 1, got $#."
show_help
exit 1
fi
Expand All @@ -66,8 +66,12 @@ if [ -n "$DOWNLOAD_SRC" ] || [ -n "$DOWNLOAD_DEST" ]; then
( cd /omnicli && ./omnicli copy "$DOWNLOAD_SRC" "$DOWNLOAD_DEST" )
fi

echo "Running command: '$1'"
$1
echo "Will run commands: '$@'"
while [[ $# -gt 0 ]]; do
echo "Running command: '$1'"
$1
shift
done

if [ -n "$UPLOAD_SRC" ] || [ -n "$UPLOAD_DEST" ]; then
echo "Copying files from '$UPLOAD_SRC' to '$UPLOAD_DEST'..."
Expand Down

0 comments on commit 86800cd

Please sign in to comment.