Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2116 - (hide annotations) (download)
Thu May 12 20:42:34 2011 UTC (13 years ago) by niro
File size: 2322 byte(s)
-exclude more files from pruning
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 2081 /etc/ld.so.conf) continue ;;
39     /etc/ld.so.cache) continue ;;
40     /etc/localtime) continue ;;
41     /etc/shadow*) continue ;;
42     /etc/gshadow*) continue ;;
43     /etc/passwd*) continue ;;
44 niro 2116 /etc/fstab) continue ;;
45 niro 2081 /etc/group*) continue ;;
46 niro 2116 /etc/host*) continue ;;
47     /etc/mage*) continue ;;
48     /etc/mtab) continue ;;
49 niro 2081 /etc/modprobe.conf) continue ;;
50 niro 2116 /etc/modprobe.d/net.*) continue ;;
51 niro 2081 /etc/resolv.conf) continue ;;
52     /etc/profile.env) continue ;;
53     /etc/rc.d/rcboot.d*) continue ;;
54     /etc/rc.d/rcsysinit.d*) continue ;;
55     /etc/rc.d/rcshutdown.d*) continue ;;
56     /etc/conf.d/net.*) continue ;;
57     /etc/dropbear*) continue ;;
58     /etc/alxconfig-ng*) continue ;;
59     /usr/mage*) continue ;;
60     /root*) continue ;;
61     /home*) continue ;;
62     /tmp*) continue ;;
63     /var/db*) continue ;;
64     /var/cache*) continue ;;
65     /var/run*) continue ;;
66     /var/tmp/magebuild*) continue ;;
67 niro 2111 # update specific
68     /.orphaned) continue ;;
69     /.dist-upgrade) continue ;;
70 niro 2081 esac
71     check_busybox ${i} && continue
72    
73     if [[ -z $(magequery -f ${i}) ]]
74     then
75     echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
76     #echo "not found -> ${i}" >> ${LOG}
77     if [[ -L ${i} ]]
78     then
79     rm ${i}
80     echo "==> deleted -> ${i}" >> ${LOG}
81    
82     elif [[ -d ${i} ]]
83     then
84     # only if not empty
85     rmdir ${i}
86     echo "==> deleted -> ${i}" >> ${LOG}
87     else
88     rm ${i}
89     echo "==> deleted -> ${i}" >> ${LOG}
90     fi
91     else
92     echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}"
93     fi
94     done
95     # remove old cruft
96     for i in /var/tmp/magebuild/virtual /var/run/samba
97     do
98     if [[ -d ${i} ]]
99     then
100     rm -rf ${i}
101     echo "==> deleted -> ${i}" >> ${LOG}
102     fi
103     done
104     for i in /var/run/dhcpcd-*.pid
105     do
106     if [[ -e ${i} ]]
107     then
108     rm -r ${i}
109     echo "==> deleted -> ${i}" >> ${LOG}
110     fi
111     done
112     # recreate fontconfig cache
113     if [ -x /usr/bin/fc-cache ]
114     then
115     HOME=/root /usr/bin/fc-cache -sr
116     fi