-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcache_remove_linux.sh
More file actions
48 lines (45 loc) · 1.41 KB
/
cache_remove_linux.sh
File metadata and controls
48 lines (45 loc) · 1.41 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
# Run our OS tests, export OS_RELEASE
source "${PT__installdir}/patching/files/bash/os_test.sh"
case $OS_RELEASE in
################################################################################
RHEL | CENTOS | FEDORA | ROCKY | OL | ALMALINUX | PHOTON)
# RedHat variant
# clean yum cache
OUTPUT=$(yum clean all 2>&1)
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
ERROR="yum clean all FAILED, you probably forgot to run this as sudo or there is a network error."
fi
;;
################################################################################
DEBIAN | UBUNTU)
# Debian variant
## Clean apt cache
OUTPUT=$(apt-get clean 2>&1)
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
ERROR="apt-get clean FAILED, you probably forgot to run this as sudo or there is a network error."
fi
;;
################################################################################
SLES)
# SUSE variant
# clean zypper cache
OUTPUT=$(zypper clean 2>&1)
STATUS=$?
if [[ $STATUS -ne 0 ]]; then
ERROR="zypper clean FAILED, you probably forgot to run this as sudo or there is a network error."
fi
;;
################################################################################
*)
ERROR="Unknown Operating System: ${OS_RELEASE}"
STATUS=2
;;
esac
if [[ $STATUS -ne 0 ]]; then
echo "ERROR: $ERROR"
echo "Output: $OUTPUT"
fi
exit $STATUS