forked from 2swap/swaptube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.sh
More file actions
executable file
·50 lines (41 loc) · 1.46 KB
/
Copy pathupload.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.46 KB
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
# !/bin/bash
#
# Shell script which uploads completed swaptube output folders recursively
# to a gcloud bucket using `gcloud storage cp` command.
# The structure of the bucket is as follows:
# gs://swaptube-out/output_uploads/video_name/run_number/...
#
# The user will provide the video name.
# The completed output folder can then be found in `out/video_name/run_number/`.
# This script will identify the latest local run for the video,
# prompt the user to confirm the upload, and then proceed to upload.
#
# The script locates the bucket ID from the file `gcskey`
# in the user's home directory.
# Argument parsing
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <project_name>"
echo "Example: $0 myproject"
exit 1
fi
PROJECT_NAME=$1
OUTPUT_FOLDER=$(ls -1d out/${PROJECT_NAME}/*/ 2>/dev/null | sort | tail -n 1)
if [ -z "$OUTPUT_FOLDER" ]; then
echo "No runs found for project '$PROJECT_NAME' in the 'out' directory."
exit 1
fi
echo
echo "Latest run for project '$PROJECT_NAME': $OUTPUT_FOLDER"
echo "Contents of the run folder:"
ls -lah "$OUTPUT_FOLDER"
echo
read -p "Do you want to upload this run to the gcloud bucket? (y/n) "
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Upload cancelled."
exit 0
fi
echo "Proceeding with upload..."
# Upload the run folder to the gcloud bucket
DESTINATION="gs://swaptube-out/output-uploads/${PROJECT_NAME}/$(basename $OUTPUT_FOLDER)"
echo "Uploading to $DESTINATION..."
gcloud storage cp --recursive "$OUTPUT_FOLDER" "$DESTINATION"