Created
May 14, 2019 13:59
-
-
Save gtfunes/a83b0ad8925585ec149af9c964c9ae38 to your computer and use it in GitHub Desktop.
A bash script for low-end machines (mostly RPis) that sometimes crash when updating too many packages at the same time
This file contains hidden or 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
#!/bin/bash | |
# - Runs apt-get upgrade for each individual package to avoid killing low-end machines - | |
DATA=$(apt-get upgrade -s -y -q | grep "Inst " | cut -d ' ' -f 2) | |
PACKAGES=(${DATA// / }) | |
Z=0 | |
for package in "${PACKAGES[@]}"; | |
do | |
echo "" | |
echo "" | |
echo "apt-get install -y -q $package" | |
bash -c "nice apt-get install -y -q $package" | |
bash -c "nice apt-get clean -y -q" | |
Z=$((Z+1)) | |
# update only first 50 packages, just to be sure that we won't kill our machine by running this script | |
if [[ $Z -eq 50 ]]; | |
then | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment