-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaintenance
executable file
·53 lines (45 loc) · 1.12 KB
/
maintenance
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
#!/usr/bin/env bash
DISTRIBUTION=`cat dist 2>/dev/null`
if [ -z "$DISTRIBUTION" ]; then
echo "No distribution?"
exit 1
fi
case "$DISTRIBUTION" in
ubuntu)
export LC_ALL="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
sudo -nA apt-get -y autoremove ||
exit 1
uname=`uname -r | sed 's%-\(server\|generic\)%%'`
purge_rc=`dpkg -l | grep '^rc' | awk '{ print $2 }'`
purge_kern=`dpkg -l | grep 'linux-\(headers\|image\)-[0-9]' | grep -v "$uname" | awk '{ print $2 }'`
if [ -n "$purge_rc" -o -n "$purge_kern" ]; then
sudo -nA apt-get -y purge $purge_rc $purge_kern ||
exit 1
fi
sudo -nA apt-get clean ||
exit 1
;;
redhat|centos)
uname=`uname -r | sed 's%\.x86_64%%'`
remove=`rpm -qa | grep '^kernel' | grep -v "$uname"`
if [ -n "$remove" ]; then
sudo -nA yum -y remove $remove ||
exit 1
fi
sudo -nA yum -y clean packages &&
sudo -nA yum -y clean expire-cache ||
exit 1
;;
sunos)
sudo -nA rm -rf ~root/.cpan/build ||
exit 1
;;
suse)
sudo -nA rm -rf ~root/.cpan/build &&
sudo -nA zypper --non-interactive-include-reboot-patches -n clean ||
exit 1
;;
esac
echo "DONE"
exit 0