Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions download_xml.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
#!/bin/bash

if [ "$#" -ne "4" ]; then
echo "Incorrect invocation: Should be download_xml.sh plugin_name plugin_version cloudsmith_user cloudsmith_level"
echo "Incorrect invocation: Should be download_xml.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level"
echo "where:"
echo " plugin_name is the name of the plugin, i.e. testplugin_pi"
echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin"
echo " plugin_version is the version number, i.e. 1.0.114.0"
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough"
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn"
echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha"
echo ""
echo " Full command should look like:"
echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough alpha"
echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough prod"
echo " download_xml.sh weather-routing 1.13.8.0 opencpn prod"
exit
fi

REPO="https://cloudsmith.io/~$3/repos/"
echo "Issuing command: lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2"
my_array=()
NAME="$1"
VERSION="$2"
USER="$3"
LEVEL="$4"

REPO="https://cloudsmith.io/~${USER}/repos/"
echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml"
echo "Show current files that match criteria"
ls metadata/$1-$2*xml -la
ls metadata/${NAME}*-*${VERSION}*xml -la
echo "Deleting current files that match criteria"
rm metadata/$1-$2*xml
rm metadata/${NAME}*-*${VERSION}*xml
echo "Finding files on remote cloudsmith repository"
while IFS= read -r line; do
my_array+=( "$line" )
done < <( lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2 )

delimiter="href=\""
delimiter1=".xml"
my_array=();
while read -r line; do
if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then
start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'`
start=$((start + ${#delimiter} - 1))
end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'`
end=$((end + 3 - start))
line=${line:$start:$end}
my_array+=( $line );
fi
done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*+tag:latest&page_size=50")
echo "Downloading files found that match criteria"
for URL in "${my_array[@]}"
do
echo $URL
echo "URL: $URL"
wget --progress=bar:force:noscroll -c $URL -P metadata
done
echo "Files downloaded"
ls metadata/$1-$2*xml -la

ls -la metadata/$NAME*-*$VERSION*xml
52 changes: 4 additions & 48 deletions download_xml_bash.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,5 @@
#!/bin/bash

if [ "$#" -ne "4" ]; then
echo "Incorrect invocation: Should be download_xml_bash.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level"
echo "where:"
echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin"
echo " plugin_version is the version number, i.e. 1.0.114.0"
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn"
echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha"
echo ""
echo " Full command should look like:"
echo " download_xml_bash.sh testplugin_pi 1.0.114.0 jon-gough prod"
echo " download_xml_bash.sh weather-routing 1.13.8.0 opencpn prod"
exit
fi

NAME="$1"
VERSION="$2"
USER="$3"
LEVEL="$4"

REPO="https://cloudsmith.io/~${USER}/repos/"
echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml"
echo "Show current files that match criteria"
ls metadata/${NAME}*-*${VERSION}*xml -la
echo "Deleting current files that match criteria"
rm metadata/${NAME}*-*${VERSION}*xml
echo "Finding files on remote cloudsmith repository"
delimiter="href=\""
delimiter1=".xml"
my_array=();
while read -r line; do
if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then
start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'`
start=$((start + ${#delimiter} - 1))
end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'`
end=$((end + 3 - start))
line=${line:$start:$end}
my_array+=( $line );
fi
done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*")
echo "Downloading files found that match criteria"
for URL in "${my_array[@]}"
do
echo "URL: $URL"
wget --progress=bar:force:noscroll -c $URL -P metadata
done
echo "Files downloaded"
ls -la metadata/$NAME*-*$VERSION*xml
echo "This script is now redundant and calls 'download_xml.sh' to process the request."
read -n 1 -s -p "Press any key to continue..."
bash ./download_xml.sh $*
exit