Skip to content

Commit

Permalink
fix update-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
aho-dips committed Jan 31, 2024
1 parent 35fef80 commit 7d51f90
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions smud-cli/download-and-install-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@ fi

mkdir $download_folder
cd $download_folder

curl --ssl-no-revoke https://api.github.com/repos/DIPSAS/smud-cli/contents/$folder --no-progress-meter -o $download_json_file

if [ ! -f "$download_json_file" ];then
echo "Missing '$download_json_file' file"
fi
download_names=($(cat $download_json_file | sed -n 's/.*"name": *"\([^"]*\)".*/\1/p'))
download_urls=$(cat $download_json_file | sed -n 's/.*"download_url": *"\([^"]*\)".*/\1/p')
download_urls=("$(cat $download_json_file | sed -n 's/.*"download_url": *"\([^"]*\)".*/\1/p')")

IFS=$'\n';read -rd '' -a download_urls <<< "$download_urls"
IFS=$'\n';read -rd '' -a download_names <<< "$download_names"
i=-1
for url in $download_urls; do
i=$((i+1))
file=${download_names[$i]}
downloaded_file=$(basename $url)
printf "${gray}Download '$file' file: ${normal}\n"
curl --ssl-no-revoke $url -o $file # > /dev/null 2>&1
echo ""
for url in "${download_urls[@]}"; do
i=$((i+1))
file=${download_names[$i]}
downloaded_file=$(basename $url)
if [ "$file" ]; then
printf "${gray}Download '$file' file: ${normal}\n"
# echo "Download:$url => $file"
curl --ssl-no-revoke $url -o $file # > /dev/null 2>&1
# echo "Downloaded"
else
echo "No file found - url=$url"
fi
echo ""
done

curl --ssl-no-revoke https://api.github.com/repos/DIPSAS/smud-cli/contents/CHANGELOG.md --no-progress-meter -o $changelog_download_json_file
Expand All @@ -37,7 +45,6 @@ changelog_download_url=$(cat $changelog_download_json_file | sed -n 's/.*"down

printf "${gray}Download '$changelog_name' file: ${normal}\n"
curl --ssl-no-revoke $changelog_download_url -o $changelog_name # > /dev/null 2>&1

rm -f "$changelog_download_json_file"

cd $curr_dir
Expand All @@ -49,9 +56,17 @@ if [ -d $download_folder ]; then
if [ -f "$download_json_file" ];then
rm -f "$download_json_file"
fi
if [ -d $download_folder ]; then
has_shell_files="$(ls $download_folder/* 2>&1 |grep .sh |tail -1)"
# echo "has_shell_files: $has_shell_files"
if [ "$has_shell_files" ]; then
cp $download_folder/*.sh $destination_folder/ -r -u
fi
if [ -f "$download_folder/.bash_aliases" ];then
cp $download_folder/.bash_aliases $destination_folder/ -r -u
fi

cp $download_folder/*.sh $destination_folder/ -r -u
cp $download_folder/.bash_aliases $destination_folder/ -r -u
fi

if [ -f "$download_folder/CHANGELOG.md" ];then
cp $download_folder/*.md $destination_folder/ -r -u
Expand Down

0 comments on commit 7d51f90

Please sign in to comment.