misc/Alpine Linux/apk-upgrade.sh
Forza 1f4101c55a Add Alpine Linux/apk-upgrade.sh
A simple script for Alpine Linux that updates the package index, checks for available package upgrades, and optionally performs the upgrade, combining `apk update`, `apk upgrade -s`, and `apk upgrade` into a single interactive workflow.
2024-11-27 22:01:21 +01:00

37 lines
725 B
Bash

#!/bin/sh
###
# For Alpine Linux
#
# A convenience script that combines
# 'apk update', 'apk upgrade -s' and 'apk upgrade'
#
# SPDX-License-Identifier: CC0-1.0
##
# Update the apk cache
printf "Updating apk cache...\n"
apk update || exit
# Check for upgradable packages
printf "\nChecking for upgradable packages..."
UPGRADABLE=$(apk upgrade -s)
if echo "$UPGRADABLE" | grep -q "Upgrading"; then
echo "The following packages can be upgraded:"
echo "$UPGRADABLE"
echo
echo "Do you want to upgrade the packages? [y/N]: "
read -r RESPONSE
case "$RESPONSE" in
[yY][eE][sS]|[yY])
echo "Upgrading packages..."
apk upgrade
;;
*)
echo "Upgrade cancelled."
;;
esac
else
echo "No packages to upgrade."
fi