Magellan Linux

Contents of /mage/branches/alx-0_6_0/profiles/alx-060/prune-orphaned-files

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2111 - (show annotations) (download)
Thu May 12 18:49:36 2011 UTC (12 years, 11 months ago) by niro
File size: 2011 byte(s)
-ignore upgrade state-files too
1 #!/bin/bash
2
3 source /etc/rc.d/init.d/functions
4
5 LOG="/root/transition.log"
6 BUSYBOX_FILES="$(</usr/share/busybox/busybox.links)"
7
8 check_busybox()
9 {
10 local file
11 local i
12 file="$1"
13
14 for i in ${BUSYBOX_FILES}
15 do
16 if [[ ${i} = ${file} ]]
17 then
18 return 0
19 fi
20 done
21
22 return 1
23 }
24
25 # clear log
26 :> ${LOG}
27
28 for i in $(find / -xdev | sort -r)
29 do
30 # excludes
31 case ${i} in
32 /etc/ld.so.conf) continue ;;
33 /etc/ld.so.cache) continue ;;
34 /etc/localtime) continue ;;
35 /etc/shadow*) continue ;;
36 /etc/gshadow*) continue ;;
37 /etc/passwd*) continue ;;
38 /etc/group*) continue ;;
39 /etc/modprobe.conf) continue ;;
40 /etc/resolv.conf) continue ;;
41 /etc/profile.env) continue ;;
42 /etc/rc.d/rcboot.d*) continue ;;
43 /etc/rc.d/rcsysinit.d*) continue ;;
44 /etc/rc.d/rcshutdown.d*) continue ;;
45 /etc/conf.d/net.*) continue ;;
46 /etc/dropbear*) continue ;;
47 /etc/alxconfig-ng*) continue ;;
48 /usr/mage*) continue ;;
49 /root*) continue ;;
50 /home*) continue ;;
51 /tmp*) continue ;;
52 /var/db*) continue ;;
53 /var/cache*) continue ;;
54 /var/run*) continue ;;
55 /var/tmp/magebuild*) continue ;;
56 # update specific
57 /.orphaned) continue ;;
58 /.dist-upgrade) continue ;;
59 esac
60 check_busybox ${i} && continue
61
62 if [[ -z $(magequery -f ${i}) ]]
63 then
64 echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
65 #echo "not found -> ${i}" >> ${LOG}
66 if [[ -L ${i} ]]
67 then
68 rm ${i}
69 echo "==> deleted -> ${i}" >> ${LOG}
70
71 elif [[ -d ${i} ]]
72 then
73 # only if not empty
74 rmdir ${i}
75 echo "==> deleted -> ${i}" >> ${LOG}
76 else
77 rm ${i}
78 echo "==> deleted -> ${i}" >> ${LOG}
79 fi
80 else
81 echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}"
82 fi
83 done
84 # remove old cruft
85 for i in /var/tmp/magebuild/virtual /var/run/samba
86 do
87 if [[ -d ${i} ]]
88 then
89 rm -rf ${i}
90 echo "==> deleted -> ${i}" >> ${LOG}
91 fi
92 done
93 for i in /var/run/dhcpcd-*.pid
94 do
95 if [[ -e ${i} ]]
96 then
97 rm -r ${i}
98 echo "==> deleted -> ${i}" >> ${LOG}
99 fi
100 done
101 # recreate fontconfig cache
102 if [ -x /usr/bin/fc-cache ]
103 then
104 HOME=/root /usr/bin/fc-cache -sr
105 fi