-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·80 lines (69 loc) · 2.11 KB
/
run.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Default image name
IMAGE_NAME="echonotes:latest"
# Usage information
usage() {
echo "Usage: ./run.sh [--image-name <docker_image_name>] --incoming <incoming_folder> --config <config_file> --prompt <markdown_file>"
echo " --image-name: Optional, Docker image name (default: echonotes:latest)"
echo " --incoming: Required, path to the folder where PDFs will be monitored"
echo " --config: Required, path to the config.yml file"
echo " --prompt: Required, path to the markdown prompt file"
exit 1
}
# Function to validate that required arguments are provided
validate_args() {
if [[ -z "$INCOMING_FOLDER" || -z "$CONFIG_FILE" || -z "$PROMPT_FILE" ]]; then
echo "Error: Missing required arguments."
usage
fi
if [[ ! -d "$INCOMING_FOLDER" ]]; then
echo "Error: Incoming folder '$INCOMING_FOLDER' does not exist."
exit 1
fi
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Error: Config file '$CONFIG_FILE' does not exist."
exit 1
fi
if [[ ! -f "$PROMPT_FILE" ]]; then
echo "Error: Prompt file '$PROMPT_FILE' does not exist."
exit 1
fi
}
# Parse named arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--image-name)
IMAGE_NAME="$2"
shift 2
;;
--incoming)
INCOMING_FOLDER="$2"
shift 2
;;
--config)
CONFIG_FILE="$2"
shift 2
;;
--prompt)
PROMPT_FILE="$2"
shift 2
;;
*)
echo "Error: Invalid argument '$1'"
usage
;;
esac
done
# Validate required arguments
validate_args
# clean up past runs
sudo rm -rf incoming/completed incoming/working incoming/* -R
# Build the Docker image
echo "Building Docker image $IMAGE_NAME..."
docker build --no-cache -t "$IMAGE_NAME" .
# Run the Docker container
echo "Running Docker container..."
docker run --rm -v "$INCOMING_FOLDER:/app/incoming" \
-v "$CONFIG_FILE:/app/config.yml" \
-v "$PROMPT_FILE:/app/summarize-notes.md" \
"$IMAGE_NAME"