Skip to content

Instantly share code, notes, and snippets.

@elanora96
Created October 20, 2024 22:04
Show Gist options
  • Save elanora96/6036dee1d40cf168f9528319a80ab4b9 to your computer and use it in GitHub Desktop.
Save elanora96/6036dee1d40cf168f9528319a80ab4b9 to your computer and use it in GitHub Desktop.
OpenWRT opkg upgrade all
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