-
Notifications
You must be signed in to change notification settings - Fork 0
/
doclean
executable file
·45 lines (34 loc) · 988 Bytes
/
doclean
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
#/bin/sh
#davids magical package cleanup/update
WORKDIR=$(pwd)
BASEDIR=$(dirname $0)
cd $BASEDIR
#remove orphaned packages
#get list of orphans
deborphan > orphans
#check package blacklist (don't remove orphans existing in the blacklist)
#sort files for comparison
sort ~/.whitelist > whitelist.tmp
sort orphans > orphans.tmp
#compare and only output orphans not existing in the blacklist
comm -1 -3 --check-order whitelist.tmp orphans.tmp > orphans
# if orphans exist, remove them.
if [[ -s orphans ]] ; then
echo "Stray Packages found"
echo "Removing..."
$aflag # flags rerun, in case of multiple orphans.
sudo apt-get --purge remove $(cat orphans)
else
echo "No stray packages today"
fi ;
#cleanup temp files
rm orphans
rm orphans.tmp whitelist.tmp
#general debian cleanup
echo "General Cleanup: autoremove & autoclean"
sudo apt-get --purge autoremove && sudo apt-get autoclean
# if there are any crumbs run again
if [ $aflag ] ; then
doclean
cd $WORKDIR
fi;