-
Notifications
You must be signed in to change notification settings - Fork 0
/
new2-update-upgrade.sh
executable file
·43 lines (37 loc) · 1.19 KB
/
new2-update-upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Function to handle package management tasks on Debian-based systems
if type apt &>/dev/null; then
manager="apt"
DISTRO="Debian/Ubuntu"
else
echo "This script is designed for Debian-based systems only."
return 1
fi
# Utility functions for separation and displaying/running commands
separator() { echo -e "\n>>>>>>>>\n"; }
displayandrun() { echo -e "\$ $*"; "$@"; }
# Update package manager
echo -e "\nCheck updates for '$DISTRO' using '$manager':"
separator
displayandrun sudo apt update --ignore-missing -y
separator
displayandrun sudo apt dist-upgrade -y
separator
displayandrun sudo apt --fix-broken install -y # Fix any broken installs
# Update apt-file if present
if type apt-file &>/dev/null; then
separator
displayandrun sudo apt-file update
fi
# Install essential packages and remove unnecessary ones
separator
displayandrun sudo apt install ca-certificates -y
separator
displayandrun sudo apt autoremove -y
# Check if a reboot is required
if [ -f /var/run/reboot-required ]; then
echo "A reboot is required (/var/run/reboot-required is present)." >&2
echo "Re-run this script after reboot to check." >&2
return
fi
echo "Update completed successfully."