Last active
July 8, 2022 21:52
-
-
Save hebertluiz/d399dc8701524e1ccba97c00ed30e99d to your computer and use it in GitHub Desktop.
Function to help install yum packages in scripts and show progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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