Created
July 11, 2024 10:56
-
-
Save ostechnix/51dedefd9b283712ff90cb1a3f818697 to your computer and use it in GitHub Desktop.
Debupdate - An Interactive Bash Shell Script to Update a Debian-based System
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
#!/usr/bin/env bash | |
# ------------------------------------------------------------------ | |
# Script Name: debupdate.sh | |
# Description: An Interactive Bash Shell Script to | |
# Update a Debian-based System | |
# Website: https://gist.github.com/ostechnix | |
# Version: 1.0 | |
# Usage: sudo ./debupdate.sh | |
# ------------------------------------------------------------------ | |
# Function to prompt for Yes, No, or Cancel input | |
prompt_for_input() { | |
while true; do | |
echo -n "Do you want to update the software package? (y/n/c): " | |
read -r response | |
case "$response" in | |
[Yy]* ) | |
echo "You selected Yes." | |
return 0 | |
;; | |
[Nn]* ) | |
echo "You selected No." | |
return 1 | |
;; | |
[Cc]* ) | |
echo "You selected Cancel." | |
return 2 | |
;; | |
* ) | |
echo "Invalid input. Please enter y, n, or c." | |
;; | |
esac | |
done | |
} | |
# Call the function and handle the return value | |
prompt_for_input | |
result=$? | |
if [ $result -eq 0 ]; then | |
echo "Proceeding with the software update..." | |
# Simulate a software update operation | |
sudo apt-get update && sudo apt-get upgrade -y | |
echo "Software update completed successfully." | |
elif [ $result -eq 1 ]; then | |
echo "Software update aborted." | |
elif [ $result -eq 2 ]; then | |
echo "Software update canceled." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment