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 2726 - (hide annotations) (download)
Wed Aug 10 22:09:51 2011 UTC (12 years, 9 months ago) by niro
File size: 2848 byte(s)
-do not prune /dev, /proc and /sys files
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     /root*) continue ;;
64     /home*) continue ;;
65 niro 2726 /proc*) continue ;;
66 niro 2081 /tmp*) continue ;;
67 niro 2726 /sys*) continue ;;
68 niro 2081 /var/db*) continue ;;
69     /var/cache*) continue ;;
70 niro 2134 /var/lib/init.d*) continue ;;
71 niro 2081 /var/run*) continue ;;
72     /var/tmp/magebuild*) continue ;;
73 niro 2111 # update specific
74     /.orphaned) continue ;;
75     /.dist-upgrade) continue ;;
76 niro 2081 esac
77     check_busybox ${i} && continue
78    
79     if [[ -z $(magequery -f ${i}) ]]
80     then
81 niro 2135 echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
82 niro 2081 #echo "not found -> ${i}" >> ${LOG}
83     if [[ -L ${i} ]]
84     then
85     rm ${i}
86     echo "==> deleted -> ${i}" >> ${LOG}
87    
88     elif [[ -d ${i} ]]
89     then
90     # only if not empty
91     rmdir ${i}
92     echo "==> deleted -> ${i}" >> ${LOG}
93     else
94     rm ${i}
95     echo "==> deleted -> ${i}" >> ${LOG}
96     fi
97     else
98     echo -e "${COLGREEN}OK${COLDEFAULT} -> ${i}"
99     fi
100     done
101     # remove old cruft
102     for i in /var/tmp/magebuild/virtual /var/run/samba
103     do
104     if [[ -d ${i} ]]
105     then
106     rm -rf ${i}
107     echo "==> deleted -> ${i}" >> ${LOG}
108     fi
109     done
110     for i in /var/run/dhcpcd-*.pid
111     do
112     if [[ -e ${i} ]]
113     then
114     rm -r ${i}
115     echo "==> deleted -> ${i}" >> ${LOG}
116     fi
117     done
118 niro 2717 # check old files in home
119     for i in .fluxbox .alxprogs .xtdesktop .xtdeskrc .ideskrc .idesktop .xinitrc
120     do
121     if [[ -f /home/station/${i} ]]
122     then
123     rm /home/station/${i}
124     echo "==> deleted -> /home/station/${i}" >> ${LOG}
125     fi
126     if [[ -d /home/station/${i} ]]
127     then
128     rm -r /home/station/${i}
129     echo "==> deleted -> /home/station/${i}" >> ${LOG}
130     fi
131     done
132 niro 2081 # recreate fontconfig cache
133     if [ -x /usr/bin/fc-cache ]
134     then
135     HOME=/root /usr/bin/fc-cache -sr
136     fi