Created
October 20, 2024 22:04
-
-
Save elanora96/6036dee1d40cf168f9528319a80ab4b9 to your computer and use it in GitHub Desktop.
OpenWRT opkg upgrade all
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
confirm() { | |
while true; do | |
read -rp "[y/n]: " yn | |
case $yn in | |
[Yy]*) return 0 ;; | |
[Nn]*) return 1 ;; | |
*) echo "Please answer yes or no." ;; | |
esac | |
done | |
} | |
opkgrade() { | |
opkg update | |
local upgrades="" | |
upgrades=$(opkg list-upgradable) | |
if [ "${#upgrades}" -eq 0 ]; then | |
echo "Nothing to do" | |
return 0 | |
fi | |
echo "$upgrades" | |
echo -n "Upgrade the above packages? " | |
if confirm; then | |
upgrades=$(echo "$upgrades" | awk '{printf "%s ", $1 }') | |
opkg upgrade ${upgrades%% } | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment