CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/software-inventory/setup.sh
Views: 923
1
#!/usr/bin/env bash
2
set -e
3
4
dist="lib/software-inventory"
5
mkdir -p $dist
6
7
# download and copy a single file
8
download_and_copy() {
9
name=$1
10
fn="software-inventory-$name.json"
11
local="software-inventory/$name.json"
12
targ="$dist/$name.json"
13
14
if [[ ! -L "$local" ]]; then
15
if ! curl --silent --show-error --fail "https://storage.googleapis.com/cocalc-compute-environment/$fn" -o "$local"; then
16
echo "Error: Failed to download $fn" >&2
17
return 1
18
fi
19
fi
20
21
cp -v "$local" "$targ"
22
}
23
24
# we now run all downloads in parallel, wait for them, and check if any of them failed...
25
pids=()
26
27
# Start downloads in parallel
28
for name in "18.04" "20.04" "22.04" "24.04"; do
29
download_and_copy "$name" &
30
pids+=($!)
31
done
32
33
# Wait for all background processes to finish
34
for pid in "${pids[@]}"; do
35
if ! wait $pid; then
36
echo "Error: One or more downloads failed" >&2
37
exit 1
38
fi
39
done
40
41