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 2134 - (hide annotations) (download)
Mon May 16 15:39:53 2011 UTC (13 years ago) by niro
File size: 2354 byte(s)
keep /var/lib/init.d
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 niro 2134 /var/lib/init.d*) continue ;;
66 niro 2081 /var/run*) continue ;;
67     /var/tmp/magebuild*) continue ;;
68 niro 2111 # update specific
69     /.orphaned) continue ;;
70     /.dist-upgrade) continue ;;
71 niro 2081 esac
72     check_busybox ${i} && continue
73    
74     if [[ -z $(magequery -f ${i}) ]]
75     then
76     echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
77     #echo "not found -> ${i}" >> ${LOG}
78     if [[ -L ${i} ]]
79     then
80     rm ${i}
81     echo "==> deleted -> ${i}" >> ${LOG}
82    
83     elif [[ -d ${i} ]]
84     then
85     # only if not empty
86     rmdir ${i}
87     echo "==> deleted -> ${i}" >> ${LOG}
88     else
89     rm ${i}
90     echo "==> deleted -> ${i}" >> ${LOG}
91     fi
92     else
93     echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}"
94     fi
95     done
96     # remove old cruft
97     for i in /var/tmp/magebuild/virtual /var/run/samba
98     do
99     if [[ -d ${i} ]]
100     then
101     rm -rf ${i}
102     echo "==> deleted -> ${i}" >> ${LOG}
103     fi
104     done
105     for i in /var/run/dhcpcd-*.pid
106     do
107     if [[ -e ${i} ]]
108     then
109     rm -r ${i}
110     echo "==> deleted -> ${i}" >> ${LOG}
111     fi
112     done
113     # recreate fontconfig cache
114     if [ -x /usr/bin/fc-cache ]
115     then
116     HOME=/root /usr/bin/fc-cache -sr
117     fi