12
12
# Determine the installation prefix
13
13
if [[ ! -n " $PREFIX " ]]; then
14
14
if echo " $OSTYPE " | grep -qE ' ^darwin.*' ; then
15
- # The `/usr` directory in macOS is read-only, so you need to change the prefix to `/usr/local`
15
+ # The `/usr` directory in macOS is read-only
16
+ # so you need to change the prefix to `/usr/local`
16
17
# https://github.com/openstreetmap/mod_tile/issues/349#issuecomment-1784165860
17
18
prefix=" /usr/local"
18
19
else
43
44
mkdir -p " $TEMP_DIR "
44
45
cd " $TEMP_DIR "
45
46
46
- echo " Downloading cli-tips executable..."
47
-
48
47
# Download the main executable script from GitHub repository
49
- curl -sLO " https://raw.githubusercontent.com/$REPO /refs/heads/main/cli-tips.sh"
48
+ echo " Downloading cli-tips executable..."
49
+ curl -sLO " https://raw.githubusercontent.com/$REPO /refs/heads/main/cli-tips.sh" &
50
50
51
- # Create translations directory and download all translation files
52
- # Uses GitHub API to get list of files, then downloads each one
51
+ # Create translations directory
53
52
mkdir -p translations
53
+
54
+ # Get list of translation files and download them in parallel
54
55
echo " Downloading translation files..."
55
- curl -s " https://api.github.com/repos/$REPO /contents/translations" | grep " download_url" | cut -d ' "' -f 4 | while read -r url; do
56
- lang=$( echo " $url " | grep -o ' [a-z]\+\.txt' | cut -d' _' -f2 | cut -d' .' -f1)
56
+ download_urls=$( curl -s " https://api.github.com/repos/$REPO /contents/translations" | grep " download_url" | cut -d ' "' -f 4)
57
57
58
+ # Function to download a single translation file
59
+ download_translation () {
60
+ local url=" $1 "
61
+ local lang=$( echo " $url " | grep -o ' [a-z]\+\.txt' | cut -d' _' -f2 | cut -d' .' -f1)
58
62
echo " - Downloading $lang translation..."
59
63
curl -LOs -C - --output-dir translations " $url "
64
+ }
65
+
66
+ # Start parallel downloads
67
+ for url in $download_urls ; do
68
+ download_translation " $url " &
60
69
done
61
70
71
+ # Wait for all downloads to complete
72
+ wait
73
+
62
74
echo " "
63
75
64
76
echo " Installing..."
@@ -67,10 +79,8 @@ $sudo mv cli-tips.sh "$prefix/bin/cli-tips"
67
79
# Set executable permissions
68
80
chmod +x " $prefix /bin/cli-tips"
69
81
70
- $sudo mkdir -p " $prefix /share/cli-tips/"
71
-
72
- # Install translation files to system share directory
73
- $sudo mv translations/* " $prefix /share/cli-tips/"
82
+ $sudo mkdir -p " $prefix /share/cli-tips"
83
+ $sudo mv translations/* " $prefix /share/cli-tips"
74
84
75
85
# Clean up temporary installation files
76
86
rm -rf " $TEMP_DIR "
0 commit comments