Magellan Linux

Annotation of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2572 - (hide annotations) (download)
Mon Jul 4 21:21:17 2011 UTC (12 years, 10 months ago) by niro
File size: 5549 byte(s)
-fixed dhcp-start
1 niro 2081 #!/bin/bash
2     # $Id$
3    
4 niro 2181 # setup exit trap for reboot
5     trap_exit()
6     {
7     if [[ -f /.dist-upgrade ]]
8     then
9     rm -f /.dist-upgrade
10     # force a reboot at this point here
11     ( sleep 3 && reboot -f & ); exit 0
12     fi
13     }
14     trap "trap_exit" EXIT
15    
16     # get a suitable environment
17     source /etc/profile
18    
19 niro 2179 MAGERC="/etc/mage.rc"
20     MAGEPROFILE="alx-060"
21     NEW_MAGE_DISTRIBUTION="unstable"
22     NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"
23     NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"
24     NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
25     NEW_MAGE_UNINSTALL_TIMEOUT=0
26    
27     CONFIGRC="/etc/alxconfig-ng/config.rc"
28     NEW_ALX_NETWORKING="dhcp"
29     NEW_ALX_DHCP_PROG="/sbin/udhcpc"
30 niro 2572 NEW_ALX_DHCP_START="-T 10 -t 5 -n -i"
31 niro 2179 NEW_ALX_DHCP_STOP=""
32 niro 2373 NEW_MIN_DISK_SPACE="85000"
33 niro 2179
34 niro 2112 read_value()
35     {
36     local file=$1
37     local var=$2
38     local value
39    
40     [[ ! -e ${file} ]] && return 1
41    
42     value=$(source ${file}; echo $(eval echo \${${var}}))
43     echo "${value}"
44     return 0
45     }
46    
47 niro 2179 updateconfig()
48     {
49     local variables="$@"
50     local value
51     local i
52 niro 2081
53 niro 2179 if [[ -z ${CONFIG} ]]
54 niro 2081 then
55 niro 2179 echo "You must define \$CONFIG varibale first!"
56     return 1
57 niro 2081 fi
58    
59 niro 2179 for i in ${variables}
60     do
61     value="$(eval echo \${NEW_${i}})"
62     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
63     then
64     echo "fixing ${i} -> ${value}"
65     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
66     else
67     echo "adding ${i}=${value}"
68     echo "${i}=\"${value}\"" >> ${CONFIG}
69     fi
70     done
71     }
72    
73     # fix mage.rc
74     CONFIG="${MAGERC}"
75     updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
76    
77     # fix config.rc
78     CONFIG="${CONFIGRC}"
79 niro 2373 updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE
80 niro 2179
81 niro 2081 # fix profile
82     if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
83     then
84     echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}"
85     ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile
86     fi
87    
88     # update mage3 -> mage4
89     if [[ -z $(magequery -n mage) ]]
90     then
91     # update mage tree
92     mage update
93    
94     # mage3 has problems with md5
95     rm -rf /usr/mage/app-mage/mage/md5
96     if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]]
97     then
98     USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage
99     elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]]
100     then
101     USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage
102     else
103     mage install mage
104     fi
105    
106     # drop all virtuals
107     :> /var/db/mage/virtuals
108    
109     # enable run of orphaned files check
110     touch /.orphaned
111 niro 2112
112     # tell that we're running an dist-upgrade
113     touch /.dist-upgrade
114 niro 2081 fi
115    
116 niro 2373 # check for -f option
117     if [[ -n $(magequery -h | grep -- -f) ]]
118     then
119     # uninstall all /usr/X11R6 packages first
120     for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')
121     do
122     mage uninstall ${i}
123     done
124     fi
125     # if /usr/X11R6 is a directoy, simply delete it with the content
126     [ -d /usr/X11R6 ] && rm -rf /usr/X11R6
127    
128 niro 2081 # install new toolchain if not exist
129     TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
130     if [[ -z $(magequery -n ${TOOLCHAIN}) ]]
131     then
132     # export bootstrap to not start any services
133     export MAGE_BOOTSTRAP=true
134     mage install ${TOOLCHAIN}
135     unset MAGE_BOOTSTRAP
136    
137     # enable run of orphaned files check
138     touch /.orphaned
139 niro 2112
140     # tell that we're running an dist-upgrade
141     touch /.dist-upgrade
142 niro 2081 fi
143    
144     # install new basesystem
145     BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)"
146     if [[ -z $(magequery -n ${BASESYSTEM}) ]]
147     then
148     # first keep some important files
149    
150     # export bootstrap to not start any services
151     export MAGE_BOOTSTRAP=true
152     mage install ${BASESYSTEM}
153     unset MAGE_BOOTSTRAP
154    
155     # enable run of orphaned files check
156     touch /.orphaned
157 niro 2112
158     # tell that we're running an dist-upgrade
159     touch /.dist-upgrade
160 niro 2081 fi
161    
162     # install remserial, if the plugin was enabled
163     if [[ ! -z $(magequery -n remserial-alx) ]]
164     then
165     mage install remserial
166    
167     # enable run of orphaned files check
168     touch /.orphaned
169     fi
170    
171 niro 2112 # etc-update
172     #etc-update
173    
174 niro 2081 # clean mage cache
175     mage clean
176    
177     echo "Searching for deprecated packages ..."
178     for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:')
179     do
180     # excludes
181     case ${i} in
182 niro 2181 alxconfig-ng) continue ;;
183     alxinstall-ng) continue ;;
184 niro 2081 kernel-alx) continue ;;
185     kernel26-alx) continue ;;
186     kernel-sources-alx) continue ;;
187     kernel26-sources-alx) continue ;;
188     esac
189    
190     echo "Removing deprecated mage-target '${i}'"
191     mage uninstall ${i}
192     done
193    
194 niro 2112 if [[ -f /.dist-upgrade ]]
195     then
196     # array of wireless opts
197     WIRELESS_OPTS=( WIRELESS_BITRATE WIRELESS_CHANNEL WIRELESS_ESSID WIRELESS_FREQUENCY WIRELESS_MODE WIRELESS_NICK WIRELESS_AUTH_MODE WIRELESS_KEY_LENGTH WIRELESS_KEY WIRELESS_KEY_ASCII WIRELESS_WPA_DRIVER )
198    
199     # fixing current dhcp network settings
200     #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*)
201     for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*)
202     do
203     case ${i} in
204     */net.sample) continue ;;
205     */net.routes) continue ;;
206     esac
207    
208     echo "fixing current dhcp network settings in '${i}'"
209     mv ${i}{,.orig}
210     onboot="$(read_value ${i}.orig ONBOOT)"
211     echo "ONBOOT=\"${onboot}\"" > ${i}
212     echo 'NETWORKING="dhcp"' >> ${i}
213     # check wireless extensions
214     for opt in ${WIRELESS_OPTS[*]}
215     do
216     value="$(read_value ${i}.orig ${opt})"
217     if [[ ! -z ${value} ]]
218     then
219     echo "${opt}=\"${value}\"" >> ${i}
220     fi
221     done
222     rm -f ${i}.orig
223     done
224 niro 2117 # search modules files
225     for i in $(find /etc/modules.d -name net.\*)
226     do
227     install -d /etc/modprobe.d
228     mv ${i} /etc/modprobe.d/${i%.conf}.conf
229     done
230 niro 2112 fi
231    
232 niro 2117 if [[ -f /.orphaned ]]
233     then
234     echo "Searching for orphaned files and directories ..."
235     bash /etc/mage-profile/prune-orphaned-files
236     rm -f /.orphaned
237     fi
238    
239 niro 2181 #if [[ -f /.dist-upgrade ]]
240     #then
241     # rm -f /.dist-upgrade
242     # # force a reboot at this point here
243     # ( reboot -f & ); exit 0
244     #fi