Skip to content

Instantly share code, notes, and snippets.

@hebertluiz
Last active July 8, 2022 21:52
Show Gist options
  • Save hebertluiz/d399dc8701524e1ccba97c00ed30e99d to your computer and use it in GitHub Desktop.
Save hebertluiz/d399dc8701524e1ccba97c00ed30e99d to your computer and use it in GitHub Desktop.
Function to help install yum packages in scripts and show progress
install_packages () {
yum install -y -q "$@" &
yum_pid=$!
spin='-\|/'
i=0
while kill -0 "${yum_pid}" 2>/dev/null; do
i=$(( (i+1) %4 ))
printf "\rInstalling Packages... ${spin:$i:1}"
sleep .1
done
if wait "${yum_pid}" ; then
echo -e "\rInstalling Packages... OK"
else
echo -e "\rInstalling Packages... FAIL"
echo "Error installing packages $*"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment