diff --git a/Alpine Linux/apk-upgrade.sh b/Alpine Linux/apk-upgrade.sh new file mode 100644 index 0000000..0adbc18 --- /dev/null +++ b/Alpine Linux/apk-upgrade.sh @@ -0,0 +1,37 @@ +#!/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 \ No newline at end of file