From 1f4101c55a44734e3c1149e95e9fa85c32025b43 Mon Sep 17 00:00:00 2001 From: Forza Date: Wed, 27 Nov 2024 22:01:21 +0100 Subject: [PATCH] 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. --- Alpine Linux/apk-upgrade.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Alpine Linux/apk-upgrade.sh 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