forked from Yenthe666/InstallScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
69 lines (55 loc) · 1.2 KB
/
update.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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
check_exit_status() {
if [ $? -eq 0 ]; then
echo
echo "Success"
echo
else
echo
echo "[ERROR] Process Failed!"
echo
read -p "The last command exited with an error. Exit script? (yes/no) " answer
if [ "$answer" == "yes" ]; then
exit 1
fi
fi
}
greeting() {
echo
echo "Hello, $USER. Let's update this system."
echo
}
update() {
sudo apt-get update
check_exit_status
if [ $(dpkg-query -W -f='${Status}' locate 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get install locate -y
fi
if [ $(dpkg-query -W -f='${Status}' mlocate 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get install mlocate -y
fi
sudo apt-get upgrade -y
check_exit_status
sudo apt-get dist-upgrade -y
check_exit_status
}
housekeeping() {
sudo apt-get autoremove -y
check_exit_status
sudo apt-get autoclean -y
check_exit_status
sudo updatedb
check_exit_status
}
leave() {
echo
echo "--------------------"
echo "- Update Complete! -"
echo "--------------------"
echo
exit
}
greeting
update
housekeeping
leave