Skip to content

Commit 703685d

Browse files
committed
use zstd if available
1 parent 14b2b24 commit 703685d

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

client/scripts/send-to-watchtower.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,25 @@ if [[ -f "current-run.tar.gz" ]]; then
88
rm current-run.tar.gz
99
fi
1010

11-
log_info "Creating \"current-run.tar.gz\""
11+
if [[ -f "current-run.tar.zst" ]]; then
12+
rm current-run.tar.zst
13+
fi
14+
15+
if command -v zstd >/dev/null 2>&1; then
16+
log_info "Creating \"current-run.tar.zst\""
1217

13-
tar --create --gzip --file="current-run.tar.gz" --directory="current-run" .
18+
tar_file_name="current-run.tar.zst"
19+
20+
tar --use-compress-program "zstd -T0 -3" --create --file="$tar_file_name" --directory="current-run" .
21+
else
22+
log_info "Creating \"current-run.tar.gz\""
23+
24+
tar_file_name="current-run.tar.gz"
25+
26+
tar --create --gzip --file="$tar_file_name" --directory="current-run" .
27+
fi
1428

15-
log_info "\"current-run.tar.gz\" file size: $(du -h "current-run.tar.gz" | cut -f1)"
29+
log_info "\"$tar_file_name\" file size: $(du -h "$tar_file_name" | cut -f1)"
1630

1731
if [[ ! -f "data/watchtower-url" ]]; then
1832
log_error "Missing data/watchtower-url" && exit 1
@@ -41,7 +55,7 @@ curl_response=$(curl --fail --silent --show-error \
4155
--header "Authorization: Bearer ${api_token}" \
4256
--header "Accept: application/json" \
4357
--form "server_uuid=${server_uuid}" \
44-
--form "bundle=@current-run.tar.gz" \
58+
--form "bundle=@$tar_file_name" \
4559
"$endpoint" 2>&1) || curl_exit_code=$?
4660

4761
if [[ ${curl_exit_code:-0} -ne 0 ]] || [[ ! "$curl_response" =~ ^Acknowledged! ]]; then

0 commit comments

Comments
 (0)