Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/prune-orphaned-files
Parent Directory | Revision Log
Revision 2817 -
(hide annotations)
(download)
Wed Aug 31 09:14:57 2011 UTC (12 years, 8 months ago) by niro
File size: 3067 byte(s)
Wed Aug 31 09:14:57 2011 UTC (12 years, 8 months ago) by niro
File size: 3067 byte(s)
- don't delete /usr/bin/X
1 | niro | 2081 | #!/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 | niro | 2116 | /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 | niro | 2726 | /dev*) continue ;; |
39 | niro | 2717 | /etc/conf.d/mkinitrd) continue ;; |
40 | niro | 2081 | /etc/ld.so.conf) continue ;; |
41 | /etc/ld.so.cache) continue ;; | ||
42 | niro | 2717 | /etc/modprobe.d/uvesafb.conf) continue;; |
43 | niro | 2081 | /etc/localtime) continue ;; |
44 | /etc/shadow*) continue ;; | ||
45 | /etc/gshadow*) continue ;; | ||
46 | /etc/passwd*) continue ;; | ||
47 | niro | 2116 | /etc/fstab) continue ;; |
48 | niro | 2081 | /etc/group*) continue ;; |
49 | niro | 2116 | /etc/host*) continue ;; |
50 | /etc/mage*) continue ;; | ||
51 | /etc/mtab) continue ;; | ||
52 | niro | 2081 | /etc/modprobe.conf) continue ;; |
53 | niro | 2116 | /etc/modprobe.d/net.*) continue ;; |
54 | niro | 2081 | /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 | niro | 2817 | /usr/bin/X) continue ;; |
64 | niro | 2081 | /root*) continue ;; |
65 | /home*) continue ;; | ||
66 | niro | 2726 | /proc*) continue ;; |
67 | niro | 2081 | /tmp*) continue ;; |
68 | niro | 2726 | /sys*) continue ;; |
69 | niro | 2081 | /var/db*) continue ;; |
70 | /var/cache*) continue ;; | ||
71 | niro | 2134 | /var/lib/init.d*) continue ;; |
72 | niro | 2081 | /var/run*) continue ;; |
73 | /var/tmp/magebuild*) continue ;; | ||
74 | niro | 2111 | # update specific |
75 | /.orphaned) continue ;; | ||
76 | /.dist-upgrade) continue ;; | ||
77 | niro | 2081 | esac |
78 | check_busybox ${i} && continue | ||
79 | |||
80 | niro | 2809 | if [[ -z $(magequery -e ${i}) ]] |
81 | niro | 2081 | then |
82 | niro | 2135 | echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}" |
83 | niro | 2081 | #echo "not found -> ${i}" >> ${LOG} |
84 | if [[ -L ${i} ]] | ||
85 | then | ||
86 | rm ${i} | ||
87 | echo "==> deleted -> ${i}" >> ${LOG} | ||
88 | |||
89 | elif [[ -d ${i} ]] | ||
90 | then | ||
91 | # only if not empty | ||
92 | rmdir ${i} | ||
93 | echo "==> deleted -> ${i}" >> ${LOG} | ||
94 | else | ||
95 | rm ${i} | ||
96 | echo "==> deleted -> ${i}" >> ${LOG} | ||
97 | fi | ||
98 | else | ||
99 | echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}" | ||
100 | fi | ||
101 | done | ||
102 | # remove old cruft | ||
103 | for i in /var/tmp/magebuild/virtual /var/run/samba | ||
104 | do | ||
105 | if [[ -d ${i} ]] | ||
106 | then | ||
107 | rm -rf ${i} | ||
108 | echo "==> deleted -> ${i}" >> ${LOG} | ||
109 | fi | ||
110 | done | ||
111 | for i in /var/run/dhcpcd-*.pid | ||
112 | do | ||
113 | if [[ -e ${i} ]] | ||
114 | then | ||
115 | rm -r ${i} | ||
116 | echo "==> deleted -> ${i}" >> ${LOG} | ||
117 | fi | ||
118 | done | ||
119 | niro | 2729 | # check old files in boot |
120 | for i in /boot/grub/grub.conf /boot/grub/grub.conf.example /boot/grub/menu.lst | ||
121 | do | ||
122 | if [[ -e ${i} ]] | ||
123 | then | ||
124 | rm -r ${i} | ||
125 | echo "==> deleted -> ${i}" >> ${LOG} | ||
126 | fi | ||
127 | done | ||
128 | niro | 2717 | # check old files in home |
129 | for i in .fluxbox .alxprogs .xtdesktop .xtdeskrc .ideskrc .idesktop .xinitrc | ||
130 | do | ||
131 | if [[ -f /home/station/${i} ]] | ||
132 | then | ||
133 | rm /home/station/${i} | ||
134 | echo "==> deleted -> /home/station/${i}" >> ${LOG} | ||
135 | fi | ||
136 | if [[ -d /home/station/${i} ]] | ||
137 | then | ||
138 | rm -r /home/station/${i} | ||
139 | echo "==> deleted -> /home/station/${i}" >> ${LOG} | ||
140 | fi | ||
141 | done | ||
142 | niro | 2081 | # recreate fontconfig cache |
143 | if [ -x /usr/bin/fc-cache ] | ||
144 | then | ||
145 | HOME=/root /usr/bin/fc-cache -sr | ||
146 | fi |