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 7975 - (hide annotations) (download)
Wed Dec 9 13:55:12 2015 UTC (8 years, 5 months ago) by niro
File size: 3115 byte(s)
-fixed whitespaces
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 2821 # never try to remove the root
78     /) continue ;;
79 niro 2081 esac
80     check_busybox ${i} && continue
81    
82 niro 2809 if [[ -z $(magequery -e ${i}) ]]
83 niro 2081 then
84 niro 2135 echo -e "${COLRED}NAK${COLDEFAULT} -> ${i}"
85 niro 2081 #echo "not found -> ${i}" >> ${LOG}
86     if [[ -L ${i} ]]
87     then
88     rm ${i}
89 niro 7975 echo "==> deleted -> ${i}" >> ${LOG}
90 niro 2081
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 niro 2729 # 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 niro 2717 # 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 niro 2081 # recreate fontconfig cache
145     if [ -x /usr/bin/fc-cache ]
146     then
147     HOME=/root /usr/bin/fc-cache -sr
148     fi