Contents of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall
Parent Directory | Revision Log
Revision 3212 -
(show annotations)
(download)
Wed Sep 14 13:29:04 2011 UTC (13 years ago) by niro
File size: 10256 byte(s)
Wed Sep 14 13:29:04 2011 UTC (13 years ago) by niro
File size: 10256 byte(s)
-load viafb for rangee devices -do not load any fb modules for zotacs, which use KMS -use uvesafb for standard pc which do not support KMS
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | # get a suitable environment |
5 | source /etc/profile |
6 | |
7 | PATH="/etc/mage-profile:${PATH}" |
8 | |
9 | MAGERC="/etc/mage.rc" |
10 | MAGEPROFILE="alx-060" |
11 | NEW_MAGE_DISTRIBUTION="unstable" |
12 | #NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" |
13 | #NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" |
14 | NEW_RSYNC="rsync://128.20.41.110/mage-alx-060" |
15 | NEW_MIRRORS="http://128.20.41.110/magellan/alx-060" |
16 | NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' |
17 | NEW_MAGE_UNINSTALL_TIMEOUT=0 |
18 | |
19 | CONFIGRC="/etc/alxconfig-ng/config.rc" |
20 | NEW_ALX_NETWORKING="dhcp" |
21 | NEW_ALX_DHCP_PROG="/sbin/udhcpc" |
22 | NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" |
23 | NEW_ALX_DHCP_STOP="" |
24 | NEW_MIN_DISK_SPACE="85000" |
25 | NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins" |
26 | NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions" |
27 | |
28 | # fake mage upgrade to prevent annoying error messages |
29 | if [[ ! -x /usr/sbin/mageupgrade ]] |
30 | then |
31 | mageupgrade() { true; }; export -f mageupgrade |
32 | fi |
33 | |
34 | 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 | updateconfig() |
48 | { |
49 | local variables="$@" |
50 | local value |
51 | local i |
52 | |
53 | if [[ -z ${CONFIG} ]] |
54 | then |
55 | echo "You must define \$CONFIG varibale first!" |
56 | return 1 |
57 | fi |
58 | |
59 | 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 | updategrub2() |
74 | { |
75 | # create a device.map |
76 | if [[ ! -f /boot/grub/device.map ]] |
77 | then |
78 | grub-mkdevicemap |
79 | fi |
80 | |
81 | # needed by grub-mkconfig on the first run |
82 | if [[ ! -f /boot/grub/video.lst ]] |
83 | then |
84 | install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst |
85 | fi |
86 | |
87 | # update grub.cfg |
88 | grub-mkconfig -o /boot/grub/grub.cfg |
89 | |
90 | # install bootloader to disk |
91 | local bootdisk |
92 | bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" |
93 | |
94 | # Generate core.img, but don't let it be installed in boot sector |
95 | grub-install --no-floppy "${bootdisk}" |
96 | } |
97 | |
98 | # checks size of the mbr, if we are able to install grub2 |
99 | check_mbr_size() |
100 | { |
101 | local hdd="$1" |
102 | local geometry_sectors |
103 | local partition_start_sector |
104 | local retval |
105 | |
106 | hdd="$(mount | grep '/dev/' | grep ' / ' | cut -d' ' -f1 | sed 's:\(.*\)[0-9].*:\1:')" |
107 | |
108 | if [[ -z ${hdd} ]] |
109 | then |
110 | echo "check_mbr_size(): No hdd given, aborting" |
111 | return 1 |
112 | fi |
113 | |
114 | # fix permissions |
115 | chmod +x /etc/mage-profile/sfdisk > /dev/null |
116 | |
117 | # default retval is 0 |
118 | retval=0 |
119 | |
120 | # check only if disk size is below 256mb |
121 | if [[ $(sfdisk -s ${hdd}) -lt 257000 ]] |
122 | then |
123 | geometry_sectors=$(sfdisk -g ${hdd} | sed 's:.*,\ \([0-9].*\)\ sectors.*:\1:') |
124 | partition_start_sector=$(sfdisk -d /dev/hda | grep /dev/hda1 | sed -e 's:.*start=\(.*\), size.*:\1:' -e 's:\ ::g') |
125 | |
126 | # check start_sector / geomtry > 1 then everything is fine, else abort setup as grub may not install! |
127 | if [[ $(expr ${partition_start_sector} / ${geometry_sectors}) -gt 1 ]] |
128 | then |
129 | echo "Current partition setup is big enough, to install grub2 mbr to this disk." |
130 | retval=0 |
131 | else |
132 | echo "Warning: Current partition setup to small, cannot install grub2 boot-sector to this disk." |
133 | echo "Maybe this is a *RANGEE* with a flash-disk =<256MB. Please re-install this client." |
134 | echo "Upgrade *not* supported!" |
135 | retval=1 |
136 | killall mage &> /dev/null |
137 | killall update-alx &> /dev/null |
138 | fi |
139 | else |
140 | echo "Current disk is big enough, to install grub2 mbr to this disk." |
141 | retval=0 |
142 | fi |
143 | |
144 | return "${retval}" |
145 | } |
146 | |
147 | # fix mage.rc |
148 | CONFIG="${MAGERC}" |
149 | updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT |
150 | |
151 | # fix config.rc |
152 | CONFIG="${CONFIGRC}" |
153 | updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS |
154 | |
155 | # fix profile |
156 | if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] |
157 | then |
158 | echo "fixing profile link -> /usr/mage/profiles/${MAGEPROFILE}" |
159 | ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile |
160 | fi |
161 | |
162 | # fix missing /dev/root device |
163 | if [[ ! -e /dev/root ]] |
164 | then |
165 | echo "fixing missing /dev/root symlink ..." |
166 | rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1)) |
167 | [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root |
168 | fi |
169 | |
170 | check_mbr_size || exit 1 |
171 | |
172 | # update mage3 -> mage4 |
173 | if [[ -z $(magequery -n mage) ]] |
174 | then |
175 | # update mage tree |
176 | mage update |
177 | |
178 | # mage3 has problems with md5 |
179 | rm -rf /usr/mage/app-mage/mage/md5 |
180 | if [[ ${NEW_MAGE_DISTRIBUTION} = unstable ]] |
181 | then |
182 | USE_UNSTABLE=true MAGE_DISTRIBUTION=unstable mage install mage |
183 | elif [[ ${NEW_MAGE_DISTRIBUTION} = testing ]] |
184 | then |
185 | USE_TESTING=true MAGE_DISTRIBUTION=testing mage install mage |
186 | else |
187 | mage install mage |
188 | fi |
189 | |
190 | # drop all virtuals |
191 | :> /var/db/mage/virtuals |
192 | |
193 | # enable run of orphaned files check |
194 | touch /.orphaned |
195 | |
196 | # tell that we're running an dist-upgrade |
197 | touch /.dist-upgrade |
198 | fi |
199 | |
200 | # only run this if X11R6 is a directory and not a symlink |
201 | if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] |
202 | then |
203 | # check for -f option |
204 | if [[ -n $(magequery -h | grep -- -f) ]] |
205 | then |
206 | # uninstall all /usr/X11R6 packages first |
207 | for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') |
208 | do |
209 | mage uninstall ${i} |
210 | done |
211 | fi |
212 | |
213 | # if there are any files after uninstall, simply delete them |
214 | [ -d /usr/X11R6 ] && rm -rf /usr/X11R6 |
215 | fi |
216 | |
217 | # install new toolchain if not exist |
218 | TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" |
219 | if [[ -z $(magequery -n ${TOOLCHAIN}) ]] |
220 | then |
221 | # export bootstrap to not start any services |
222 | export MAGE_BOOTSTRAP=true |
223 | mage install ${TOOLCHAIN} |
224 | unset MAGE_BOOTSTRAP |
225 | |
226 | # enable run of orphaned files check |
227 | touch /.orphaned |
228 | |
229 | # tell that we're running an dist-upgrade |
230 | touch /.dist-upgrade |
231 | fi |
232 | |
233 | # install new basesystem |
234 | BASESYSTEM="$(< /etc/mage-profile/basesystem.defaults)" |
235 | if [[ -z $(magequery -n ${BASESYSTEM}) ]] |
236 | then |
237 | # first keep some important files |
238 | |
239 | # export bootstrap to not start any services |
240 | export MAGE_BOOTSTRAP=true |
241 | mage install ${BASESYSTEM} |
242 | unset MAGE_BOOTSTRAP |
243 | |
244 | # # fix locale |
245 | # echo "LANG=\"de_DE\"" > /etc/conf.d/locale |
246 | |
247 | # enable run of orphaned files check |
248 | touch /.orphaned |
249 | |
250 | # tell that we're running an dist-upgrade |
251 | touch /.dist-upgrade |
252 | fi |
253 | |
254 | # install remserial, if the plugin was enabled |
255 | if [[ ! -z $(magequery -n remserial-alx) ]] |
256 | then |
257 | mage install remserial |
258 | |
259 | # enable run of orphaned files check |
260 | touch /.orphaned |
261 | fi |
262 | |
263 | # clean mage cache |
264 | mage clean |
265 | |
266 | echo "Searching for deprecated packages ..." |
267 | for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:') |
268 | do |
269 | # excludes |
270 | case ${i} in |
271 | alxconfig-ng) continue ;; |
272 | alxinstall-ng) continue ;; |
273 | kernel-alx) continue ;; |
274 | kernel26-alx) continue ;; |
275 | kernel-sources-alx) continue ;; |
276 | kernel26-sources-alx) continue ;; |
277 | esac |
278 | |
279 | echo "Removing deprecated mage-target '${i}'" |
280 | mage uninstall ${i} |
281 | done |
282 | |
283 | if [[ -f /.orphaned ]] |
284 | then |
285 | echo "Searching for orphaned files and directories ..." |
286 | bash /etc/mage-profile/prune-orphaned-files |
287 | rm -f /.orphaned |
288 | fi |
289 | |
290 | if [[ -f /.dist-upgrade ]] |
291 | then |
292 | # busybox gets installed before the new busybox initscripts |
293 | # and the syslog daemon gets started at the wrong runlevels (rc3.d instead of rc.sysinit) |
294 | # these runlevel symlinks will be deleted by the prune-orphaned-files script |
295 | # and syslogd will be left never started. so add syslogd here |
296 | rc-config add syslogd |
297 | |
298 | # array of wireless opts |
299 | 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 ) |
300 | |
301 | # fixing current dhcp network settings |
302 | #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*) |
303 | for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*) |
304 | do |
305 | case ${i} in |
306 | */net.sample) continue ;; |
307 | */net.routes) continue ;; |
308 | esac |
309 | |
310 | echo "fixing current dhcp network settings in '${i}'" |
311 | mv ${i}{,.orig} |
312 | onboot="$(read_value ${i}.orig ONBOOT)" |
313 | echo "ONBOOT=\"${onboot}\"" > ${i} |
314 | echo 'NETWORKING="dhcp"' >> ${i} |
315 | # check wireless extensions |
316 | for opt in ${WIRELESS_OPTS[*]} |
317 | do |
318 | value="$(read_value ${i}.orig ${opt})" |
319 | if [[ ! -z ${value} ]] |
320 | then |
321 | echo "${opt}=\"${value}\"" >> ${i} |
322 | fi |
323 | done |
324 | rm -f ${i}.orig |
325 | done |
326 | # search modules files |
327 | for i in $(find /etc/modules.d -name net.\*) |
328 | do |
329 | install -d /etc/modprobe.d |
330 | mv ${i} /etc/modprobe.d/${i%.conf}.conf |
331 | done |
332 | |
333 | mount /boot &> /dev/null |
334 | # install an appropriate uvesafb.conf |
335 | install -d /etc/modprobe.d || die |
336 | echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die |
337 | # install an appropriate viafb.conf |
338 | echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > /etc/modprobe.d/viafb.conf || die |
339 | # create an updated initrd |
340 | DISKMODS="sd_mod" |
341 | OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
342 | PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
343 | SATAMODS="sata_via sata_sis sata_nv" |
344 | DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
345 | if [ -x /usr/sbin/alx-hwdetection ] |
346 | then |
347 | case $(/usr/sbin/alx-hwdetection system) in |
348 | zotac) FBMODS="" ;; |
349 | rangee) FBMODS="viafb" ;; |
350 | standard) FBMODS="uvesafb" ;; |
351 | # unkown, use nothing to be safe |
352 | *) FBMODS="" ;; |
353 | esac |
354 | else |
355 | # unkown, use nothing to be safe |
356 | FBMODS="" |
357 | fi |
358 | echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd |
359 | kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') |
360 | # run depmod before |
361 | depmod -aF /boot/System.map-${kernelver} |
362 | mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} |
363 | # update grub bootloader |
364 | updategrub2 |
365 | fi |
366 | |
367 | if [[ -f /.dist-upgrade ]] |
368 | then |
369 | echo "preparing for a reboot in 60 seconds ..." |
370 | # reboot via cronjob |
371 | [[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs |
372 | # setup a proper cronjob |
373 | tmp=$(mktemp) |
374 | :> ${tmp} |
375 | # fake mageupgrade to fix annoying error messages |
376 | if [[ ! -x /sbin/mageupgrade ]] |
377 | then |
378 | echo '#!/bin/sh' > /sbin/mageupgrade |
379 | echo 'exit 0' >> /sbin/mageupgrade |
380 | chmod +x /sbin/mageupgrade |
381 | echo "* * * * * rm /sbin/mageupgrade" >> ${tmp} |
382 | fi |
383 | echo "* * * * * crontab -r && reboot -f" >> ${tmp} |
384 | crontab ${tmp} |
385 | [[ -f ${tmp} ]] && rm -f ${tmp} |
386 | # start cron daemon in background |
387 | crond -b -S |
388 | |
389 | rm -f /.dist-upgrade |
390 | fi |
391 | |
392 | exit 0 |