-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoUpdate.sh
executable file
·56 lines (44 loc) · 1.24 KB
/
AutoUpdate.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
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Updates the system with a single command line call to simplify my life
# /etc/P5Software/Linux-Tools/AutoUpdate.sh
# Brent Andrew Hendricks
# 3 June 2018
#Colors
CYAN='\033[0;36m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Make sure we're running as root
if ! [ $(id -u) = 0 ]; then
echo -e "\n${RED}Please use sudo or root to run this script.${NC}\n"
exit 1
fi
#Update apt
echo -e "\n${CYAN}Updating apt package lists.${NC}"
apt-get update
responseCode=$?
if [ $responseCode != 0 ]; then
echo -e "\n${RED}Error: ${NC}$responseCode"
exit $responseCode
fi
#Upgrade the distribution and packages
echo -e "\n${CYAN}Upgrading packages and kernel using dist-upgrade.${NC}"
apt-get dist-upgrade -y
responseCode=$?
if [ $responseCode != 0 ]; then
echo -e "\n${RED}Error: ${NC}$responseCode"
exit $responseCode
fi
#Remove old package versions to save space
echo -e "\n${CYAN}Removing old packages.${NC}"
apt-get autoremove -y
responseCode=$?
if [ $responseCode != 0 ]; then
echo -e "\n${RED}Error: ${NC}$responseCode"
exit $responseCode
fi
echo -e "\n${CYAN}Complete.${NC}"
#Notify the user if a reboot is required
if [ -f /var/run/reboot-required ]; then
echo -e "\n${RED}A reboot is required.${NC}\n"
fi
exit 0