Skip to content

Commit

Permalink
fix(install): validate download before continuing
Browse files Browse the repository at this point in the history
resolves #4339
  • Loading branch information
JanDeDobbeleer committed Oct 18, 2023
1 parent cb932ac commit 849c60f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions website/static/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ install() {
info "⬇️ Downloading oh-my-posh from ${url}"

http_response=$(curl -s -f -L $url -o $executable -w "%{http_code}")
if [ $http_response != "200" ]; then
error "Unable to download executable at ${url}\nPlease validate your connection and/or proxy settings"

if [ $http_response != "200" ] || [ ! -f $executable ]; then
error "Unable to download executable at ${url}\nPlease validate your curl, connection and/or proxy settings"
fi

chmod +x $executable
Expand All @@ -139,15 +140,19 @@ install() {
info "🎨 Installing oh-my-posh themes in ${cache_dir}/themes\n"

theme_dir="${cache_dir}/themes"
url="https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip"
mkdir -p $theme_dir
http_response=$(curl -s -f -L $url -o ${cache_dir}/themes.zip -w "%{http_code}")
if [ $http_response == "200" ]; then
unzip -o -q ${cache_dir}/themes.zip -d $theme_dir
zip_file="${cache_dir}/themes.zip"

url="https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip"

http_response=$(curl -s -f -L $url -o $zip_file -w "%{http_code}")

if [ $http_response == "200" ] && [ -f $zip_file ]; then
unzip -o -q $zip_file -d $theme_dir
chmod u+rw ${theme_dir}/*.omp.*
rm ${cache_dir}/themes.zip
rm $zip_file
else
warn "Unable to download themes at ${url}\nPlease validate your connection and/or proxy settings"
warn "Unable to download themes at ${url}\nPlease validate your curl, connection and/or proxy settings"
fi

info "🚀 Installation complete.\n\nYou can follow the instructions at https://ohmyposh.dev/docs/installation/prompt"
Expand Down

0 comments on commit 849c60f

Please sign in to comment.