[fix] making this work with sh...wondering if supporting the few shells that don't have bash is worth losing array functionality.
This commit is contained in:
@@ -169,21 +169,27 @@ if [ $COMMAND = "download" ]; then
|
|||||||
release_id=$(curl -s $LIBPOSTAL_RELEASE_API_URL/tags/$LIBPOSTAL_RELEASE_VERSION_STRING | grep "\"id\"" | head -n1 | grep -o '[0-9][0-9]*')
|
release_id=$(curl -s $LIBPOSTAL_RELEASE_API_URL/tags/$LIBPOSTAL_RELEASE_VERSION_STRING | grep "\"id\"" | head -n1 | grep -o '[0-9][0-9]*')
|
||||||
release_assets="$(curl -s $LIBPOSTAL_RELEASE_API_URL/$release_id/assets)"
|
release_assets="$(curl -s $LIBPOSTAL_RELEASE_API_URL/$release_id/assets)"
|
||||||
|
|
||||||
asset_names=($(echo "$release_assets" | grep -o '"name": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"'))
|
asset_names_tempfile="asset_names.tmp"
|
||||||
asset_metadata_urls=($(echo "$release_assets" | grep -o '"url": *"[^"]*/releases/assets/[0-9]*"' | grep -o '"[^"]*"$' | tr -d '"'))
|
echo "$release_assets" | grep -o '"name": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' > $asset_names_file
|
||||||
asset_urls=($(echo "$release_assets" | grep -o '"browser_download_url": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"'))
|
asset_metadata_tempfile="asset_metadata.tmp"
|
||||||
|
echo "$release_assets" | grep -o '"url": *"[^"]*/releases/assets/[0-9]*"' | grep -o '"[^"]*"$' | tr -d '"' > $asset_metadata_tempfile
|
||||||
|
asset_urls_tempfile="asset_urls.tmp"
|
||||||
|
echo "$release_assets" | grep -o '"browser_download_url": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' > $asset_urls_tempfile
|
||||||
|
asset_sizes_tempfile="asset_sizes.tmp"
|
||||||
|
echo "$release_assets" | grep -o '"size": *[0-9]*' | grep -o '[0-9]*$' > $asset_sizes_tempfile
|
||||||
|
|
||||||
num_assets=${#asset_names[*]}
|
assets_tempfile="assets.tmp"
|
||||||
|
paste -d' ' $asset_names_tempfile $asset_metadata_tempfile $asset_urls_tempfile $asset_sizes_tempfile > $assets_tempfile
|
||||||
|
|
||||||
asset_sizes=($(echo "$release_assets" | grep -o '"size": *[0-9]*' | grep -o '[0-9]*$'))
|
rm $asset_names_tempfile $asset_metadata_tempfile $asset_urls_tempfile $asset_sizes_tempfile
|
||||||
|
|
||||||
for i in $(seq 0 $((num_assets - 1))); do
|
while read -r line; do
|
||||||
asset=${asset_names[i]};
|
asset=$(echo "$line" | cut -f1 -d' ')
|
||||||
asset_metadata_url=${asset_metadata_urls[i]};
|
asset_metadata_url=$(echo "$line" | cut -f2 -d' ')
|
||||||
asset_url=${asset_urls[i]};
|
asset_url=$(echo "$line" | cut -f3 -d' ')
|
||||||
asset_size=${asset_sizes[i]};
|
asset_size=$(echo "$line" | cut -f4 -d' ')
|
||||||
|
|
||||||
if [ $asset = $LIBPOSTAL_DATA_FILE ] && ([ $FILE = "base" ] || [ $FILE == "all" ]); then
|
if [ $asset = $LIBPOSTAL_DATA_FILE ] && ([ $FILE = "base" ] || [ $FILE = "all" ]); then
|
||||||
download_file $LIBPOSTAL_DATA_UPDATED_PATH $LIBPOSTAL_DATA_DIR $asset_metadata_url $asset_url $asset_size $LIBPOSTAL_DATA_FILE "data file" $BASIC_MODULE_DIRS
|
download_file $LIBPOSTAL_DATA_UPDATED_PATH $LIBPOSTAL_DATA_DIR $asset_metadata_url $asset_url $asset_size $LIBPOSTAL_DATA_FILE "data file" $BASIC_MODULE_DIRS
|
||||||
fi
|
fi
|
||||||
if [ $asset = $LIBPOSTAL_PARSER_FILE ] && ([ $FILE = "parser" ] || [ $FILE = "all" ]); then
|
if [ $asset = $LIBPOSTAL_PARSER_FILE ] && ([ $FILE = "parser" ] || [ $FILE = "all" ]); then
|
||||||
@@ -196,7 +202,8 @@ if [ $COMMAND = "download" ]; then
|
|||||||
if [ "$LIBPOSTAL_DATA_DIR_VERSION" != "$LIBPOSTAL_VERSION_STRING" ]; then
|
if [ "$LIBPOSTAL_DATA_DIR_VERSION" != "$LIBPOSTAL_VERSION_STRING" ]; then
|
||||||
echo $LIBPOSTAL_VERSION_STRING > $LIBPOSTAL_DATA_VERSION_FILE;
|
echo $LIBPOSTAL_VERSION_STRING > $LIBPOSTAL_DATA_VERSION_FILE;
|
||||||
fi
|
fi
|
||||||
done
|
done < $assets_tempfile;
|
||||||
|
rm $assets_tempfile
|
||||||
|
|
||||||
elif [ $COMMAND = "upload" ]; then
|
elif [ $COMMAND = "upload" ]; then
|
||||||
echo "upload not implemented yet"
|
echo "upload not implemented yet"
|
||||||
|
|||||||
Reference in New Issue
Block a user