Magellan Linux

Contents of /mage/trunk/profiles/alx-060/prune-orphaned-files

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3122 - (show annotations) (download)
Thu Sep 8 19:25:26 2011 UTC (12 years, 7 months ago) by niro
File size: 3117 byte(s)
-merged changes from the 0.6.0 branch
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 /boot/boot*) continue ;;
33 /boot/grub*) continue ;;
34 /boot/vmlinuz) continue ;;
35 /boot/System.map) continue ;;
36 /boot/config) continue ;;
37 /boot/initrd) continue ;;
38 /dev*) continue ;;
39 /etc/conf.d/mkinitrd) continue ;;
40 /etc/ld.so.conf) continue ;;
41 /etc/ld.so.cache) continue ;;
42 /etc/modprobe.d/uvesafb.conf) continue;;
43 /etc/localtime) continue ;;
44 /etc/shadow*) continue ;;
45 /etc/gshadow*) continue ;;
46 /etc/passwd*) continue ;;
47 /etc/fstab) continue ;;
48 /etc/group*) continue ;;
49 /etc/host*) continue ;;
50 /etc/mage*) continue ;;
51 /etc/mtab) continue ;;
52 /etc/modprobe.conf) continue ;;
53 /etc/modprobe.d/net.*) continue ;;
54 /etc/resolv.conf) continue ;;
55 /etc/profile.env) continue ;;
56 /etc/rc.d/rcboot.d*) continue ;;
57 /etc/rc.d/rcsysinit.d*) continue ;;
58 /etc/rc.d/rcshutdown.d*) continue ;;
59 /etc/conf.d/net.*) continue ;;
60 /etc/dropbear*) continue ;;
61 /etc/alxconfig-ng*) continue ;;
62 /usr/mage*) continue ;;
63 /usr/bin/X) continue ;;
64 /root*) continue ;;
65 /home*) continue ;;
66 /proc*) continue ;;
67 /tmp*) continue ;;
68 /sys*) continue ;;
69 /var/db*) continue ;;
70 /var/cache*) continue ;;
71 /var/lib/init.d*) continue ;;
72 /var/run*) continue ;;
73 /var/tmp/magebuild*) continue ;;
74 # update specific
75 /.orphaned) continue ;;
76 /.dist-upgrade) continue ;;
77 # never try to remove the root
78 /) continue ;;
79 esac
80 check_busybox ${i} && continue
81
82 if [[ -z $(magequery -e ${i}) ]]
83 then
84 echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
85 #echo "not found -> ${i}" >> ${LOG}
86 if [[ -L ${i} ]]
87 then
88 rm ${i}
89 echo "==> deleted -> ${i}" >> ${LOG}
90
91 elif [[ -d ${i} ]]
92 then
93 # only if not empty
94 rmdir ${i}
95 echo "==> deleted -> ${i}" >> ${LOG}
96 else
97 rm ${i}
98 echo "==> deleted -> ${i}" >> ${LOG}
99 fi
100 else
101 echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}"
102 fi
103 done
104 # remove old cruft
105 for i in /var/tmp/magebuild/virtual /var/run/samba
106 do
107 if [[ -d ${i} ]]
108 then
109 rm -rf ${i}
110 echo "==> deleted -> ${i}" >> ${LOG}
111 fi
112 done
113 for i in /var/run/dhcpcd-*.pid
114 do
115 if [[ -e ${i} ]]
116 then
117 rm -r ${i}
118 echo "==> deleted -> ${i}" >> ${LOG}
119 fi
120 done
121 # check old files in boot
122 for i in /boot/grub/grub.conf /boot/grub/grub.conf.example /boot/grub/menu.lst
123 do
124 if [[ -e ${i} ]]
125 then
126 rm -r ${i}
127 echo "==> deleted -> ${i}" >> ${LOG}
128 fi
129 done
130 # check old files in home
131 for i in .fluxbox .alxprogs .xtdesktop .xtdeskrc .ideskrc .idesktop .xinitrc
132 do
133 if [[ -f /home/station/${i} ]]
134 then
135 rm /home/station/${i}
136 echo "==> deleted -> /home/station/${i}" >> ${LOG}
137 fi
138 if [[ -d /home/station/${i} ]]
139 then
140 rm -r /home/station/${i}
141 echo "==> deleted -> /home/station/${i}" >> ${LOG}
142 fi
143 done
144 # recreate fontconfig cache
145 if [ -x /usr/bin/fc-cache ]
146 then
147 HOME=/root /usr/bin/fc-cache -sr
148 fi