-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallUpdates.sh
More file actions
48 lines (41 loc) · 1.11 KB
/
installUpdates.sh
File metadata and controls
48 lines (41 loc) · 1.11 KB
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
#!/bin/bash
detect_os() {
grep -qis "$*" /etc/issue || grep -qis "$*" /etc/centos-release
}
do_update() {
echo "Detecting OS ... "
detect_os "Debian GNU/Linux" && echo "Found Debian" && dpkg_update && return
detect_os "Ubuntu" && echo "Found Ubuntu" && dpkg_update && return
detect_os "CentOS" && echo "Found CenOS" && yum_update && return
detect_os "Red Hat" && echo "Found RedHat" && yum_update && return
detect_os "Fedora" && echo "Found Fedora" && yum_update && return
detect_os "SUSE" && echo "Found SuSE" && zypper_update && return
}
dpkg_update() {
if [ -x "/usr/bin/apt-get" ];
then
echo "Starting update ..."
apt-get clean && apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
else
echo "'apt-get' package manager not found"
fi
}
yum_update() {
if [ -x "/usr/bin/yum" ];
then
echo "Starting update ..."
yum update -y && yum upgrade -y
else
echo "'yum' package manager not found"
fi
}
zypper_update() {
if [ -x "/usr/bin/zypper" ];
then
echo "Starting update ..."
zypper --non-interactive update
else
echo "'zypper' package manager not found"
fi
}
do_update