Magellan Linux

Contents of /alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 260 - (show annotations) (download) (as text)
Mon Apr 18 20:27:57 2005 UTC (19 years ago) by niro
File MIME type: application/x-sh
File size: 15728 byte(s)
fixed some issues when started from init

1 #!/bin/sh
2 #
3 # $Header: /home/cvsd/alx-cvs/alx-src/alxinstall-ng/bin/alxinstall-ng.sh,v 1.2 2005-04-18 20:27:57 niro Exp $
4 #
5 # AutoSta_LX Installation Script
6 # version: 0.8b
7 #
8 # Niels Rogalla <niro@magellan-linux.de>
9 # <rogalla@augusta-bochum.de>
10 #
11 #
12 # Install Navigation Gui
13 #
14
15 #source /etc/alx_version
16 #source /opt/alx-config/version
17
18 #source /etc/alx-config/config.rc
19
20 #images: (get ${CDIMAGENAME})
21 source /mnt/cdrom/system/images.conf
22
23 #Includes
24 source /usr/lib/alxinstall-ng/functions/findhdd.sh > /dev/null
25 ### bugfix ###############################
26 cdromdev="`echo $cdromdev|sed -e 's/ //'`"
27 ########################################
28
29 ### System/Config Version
30 VERSION="0.1"
31 TITLE="alxinstall-ng - ${VERSION}"
32
33 #CONFIGS_TEMPLATE="/opt/alx-config/configs"
34
35 CDPATH="/mnt/cdrom"
36 INSTALLPATH="/mnt/magellan"
37
38 ### WICHTIG: anzahl lines in der autosta_lx.tar.gz -1
39 CURRENTLINE=0
40 #TOTALLINES=11072 # -> now in images.conf
41
42
43 #################################################
44 # DIALOG BOXEN #
45 #################################################
46
47 die() {
48 #clear
49 #echo -e "\nhuch, da ist ein script gestorben -> $?\n"
50 #read
51 #exit 0
52 ERROR=$1
53 RETVAL=$?
54 dialog_install_failure
55 exit 1
56 }
57
58 dialog_warning() {
59 dialog \
60 --backtitle "$TITLE" \
61 --colors \
62 --defaultno \
63 --yesno "\Z1 !!! Achtung !!! \Zn\n\n\
64 Diese Festplatte wird unwiederruflich geloescht werden.\n\n\
65 Soll ich wirklich fortfahren ?" 10 70
66 RES=$?
67 if [ "$RES" == "1" ]
68 then
69 clear
70 echo "Der Vorgang wurde abgebrochen."
71 exit 1
72 fi
73 }
74
75 dialog_setup_hdd_info(){
76 local SHDD="`echo $HDD|sed -e 's/\/dev\///'`"
77
78 dialog \
79 --colors \
80 --title "[ Festplatten Partitionierung ]" \
81 --backtitle "$TITLE" \
82 --ok-label "Weiter" \
83 --msgbox "\nBitte legen Sie 3 Partitionen an.\n\n\
84 [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\
85 [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux Swap\Zn mit ca. 256MB\n\
86 [ \Z3${SHDD}3\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\
87 Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81
88 }
89
90 dialog_setup_hdd_menu() {
91
92 I=`dialog \
93 --backtitle "$TITLE" \
94 --title "[ Festplatten Partitionierung ]" \
95 --cancel-label "Abbrechen" \
96 --ok-label "Weiter" \
97 --stdout \
98 --menu "\nWaehlen Sie zwischen Manuell und Automatisch" 14 70 5 \
99 "1" "Manuell" \
100 "2" "Automatisch"`
101 RES=$?
102 if [ "$RES" == "1" ];then
103 return 1
104 fi
105 if [ "$RES" == "0" ];then
106 case "$I" in
107 "1")
108 dialog_setup_hdd_found_manuell
109 ;;
110 "2")
111 dialog_warning
112 setup_hdd_partitions_silent
113 ;;
114 esac
115 fi
116 }
117
118 dialog_setup_hdd_found_manuell() {
119 if [ ! -z "$installdevs" ]
120 then
121 installdevs=""
122 fi
123
124 echo "dialog \\" > /tmp/hddtmp.sh
125 echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh
126 echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh
127 echo "--stdout \\" >> /tmp/hddtmp.sh
128 echo "--colors \\" >> /tmp/hddtmp.sh
129 echo "--msgbox \"Gefundene Hardware:\n\n \\" >> /tmp/hddtmp.sh
130 echo " Festplatten:\n \\" >> /tmp/hddtmp.sh
131
132 if [ ! -z "$scsidisks" ]
133 then
134 for I in $scsidisks
135 do
136 if [ "$I" != "$cdromdev" ]
137 then
138 echo " \\Z7SCSI: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh
139 installdevs="$installdevs $I"
140 fi
141 done
142 fi
143
144 if [ ! -z "$idedisks" ]
145 then
146 for I in $idedisks
147 do
148 if [ "$I" != "$cdromdev" ]
149 then
150 echo " \\Z7IDE: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh
151 installdevs="$installdevs $I"
152 fi
153 done
154 fi
155
156 if [ ! -z "$cdromdev" ]
157 then
158 echo " \n \\" >> /tmp/hddtmp.sh
159 echo " \\Z7andere Laufwerke:\n \\" >> /tmp/hddtmp.sh
160 echo " CDROM: \\Z3$cdromdev\\Zn\n \\" >> /tmp/hddtmp.sh
161 fi
162 echo " \" 13 70" >> /tmp/hddtmp.sh
163 chmod a+x /tmp/hddtmp.sh
164 /tmp/hddtmp.sh
165 }
166
167 dialog_setup_hdd_partitions_manuell() {
168 if [ -z "$installdevs" ]
169 then
170 dialog \
171 --backtitle "$TITLE" \
172 --ok-label "Beenden" \
173 --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70
174 exit 1
175 else
176
177 echo "dialog \\" > /tmp/hddtmp.sh
178 echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh
179 echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh
180 echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh
181 echo "--stdout \\" >> /tmp/hddtmp.sh
182 echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh
183
184 for I in $installdevs
185 do
186 echo "\"$I\" \"\" \\" >> /tmp/hddtmp.sh
187 done
188 echo -e "\n" >> /tmp/hddtmp.sh
189
190 chmod a+x /tmp/hddtmp.sh
191 HDD="`/tmp/hddtmp.sh`"
192 RES=$?
193 if [ "$RES" == "1" ]
194 then
195 return 1
196 fi
197 if [ "$RES" == "0" ]
198 then
199 dialog_setup_hdd_info
200 setup_hdd_partitions_manuell
201 fi
202 fi
203 }
204
205 dialog_setup_hdd_partitions_silent() {
206 dialog \
207 --backtitle "$TITLE" \
208 --infobox "Erstelle Partitionen ..." 3 70
209 }
210
211 dialog_setup_hdd_format() {
212 dialog \
213 --backtitle "$TITLE" \
214 --infobox "Erstelle Datei-Systeme ..." 3 70
215 }
216
217 dialog_install_settings() {
218 dialog \
219 --backtitle "$TITLE" \
220 --infobox "Speichere System-Einstellungen ..." 3 70
221 }
222
223 dialog_install_system_image() {
224 dialog \
225 --backtitle "$TITLE" \
226 --gauge "Kopiere System-Image ..." 6 80
227 }
228
229 dialog_install_meter() {
230 while [ "${CURRENTLINE}" != "${TOTALLINES}" ] ; do
231 CURRENTLINE=`grep --count . /tmp/install.log`
232 PERCENT=`expr ${CURRENTLINE} \* 100 / ${TOTALLINES}`
233 echo ${PERCENT}
234 sleep 1
235 done
236 rm -f /tmp/install.log
237 return 0
238 }
239
240
241 dialog_install_bootsector() {
242 dialog \
243 --backtitle "$TITLE" \
244 --infobox "Schreibe den Bootsektor ..." 3 70
245 }
246
247 dialog_install_alxconfig() {
248 dialog \
249 --backtitle "$TITLE" \
250 --infobox "Installiere die ALX Setup-Tools ..." 3 70
251 }
252
253 dialog_install_kernel_image() {
254 dialog \
255 --backtitle "$TITLE" \
256 --infobox "Installiere den System-Kernel ..." 3 70
257
258 }
259
260 dialog_install_hotfixes() {
261 dialog \
262 --backtitle "$TITLE" \
263 --infobox "Installiere Hotfixes ..." 3 70
264
265 }
266
267 dialog_install_successful() {
268 dialog \
269 --backtitle "$TITLE" \
270 --colors \
271 --msgbox "Die Installation war \Z2erfolgreich\Zn." 5 81
272 }
273
274 dialog_install_failure() {
275 dialog \
276 --backtitle "$TITLE" \
277 --colors \
278 --msgbox "Die Installation ist \Z1Fehlgeschlagen\Zn.\n\n\
279 Fehler bei $ERROR, RetVal: $RETVAL \
280 " 10 81
281 }
282
283 dialog_install_method() {
284
285 METHOD=`dialog \
286 --backtitle "$TITLE" \
287 --cancel-label "Abbrechen" \
288 --ok-label "Weiter" \
289 --stdout \
290 --menu "Konfiguration" 14 70 5 \
291 "1" "Normale Installation" \
292 "2" "Silent Installation"`
293 RES=$?
294 if [ "$RES" == "1" ];then
295 return 1
296 fi
297 if [ "$RES" == "0" ];then
298 case "$METHOD" in
299 "1")
300 run_install_normal
301 ;;
302 "2")
303 dialog_warning
304 run_install_silent
305 ;;
306 esac
307 fi
308 }
309
310 dialog_main() {
311 METHOD=0
312
313 while [ $METHOD -le 2 ]
314 do
315 METHOD=`dialog \
316 --backtitle "$TITLE" \
317 --no-cancel \
318 --ok-label "Weiter" \
319 --stdout \
320 --menu "Konfiguration" 14 70 5 \
321 "1" "AutoSta_LX installieren" \
322 "2" "Uebersicht gefundener Laufwerke" \
323 "3" "Beenden und neustarten" \
324 "4" "Beenden und eine Shell starten" `
325 RES=$?
326 if [ "$RES" == "1" ];then
327 exit 1
328 fi
329 if [ "$RES" == "0" ];then
330 case "$METHOD" in
331 "1")
332 #only for now later it will be used again
333 #with 6.1-r2 only one install method available
334 #dialog_install_method
335 run_install_normal
336 ;;
337 "2") dialog_setup_hdd_found_manuell
338 ;;
339 "3") install_do_reboot
340 ;;
341 "4") /bin/bash --login -i
342 ;;
343 esac
344 fi
345 done
346 }
347
348 #################################################
349 # Install Komandos #
350 #################################################
351 setup_hdd_partitions_manuell() {
352 BOOTHDD="${HDD}1"
353 SWAPHDD="${HDD}2"
354 ROOTHDD="${HDD}3"
355
356 ## hdds partitionieren manuell
357 cfdisk $HDD || die
358 }
359
360 setup_hdd_partitions_silent() {
361 ## hdds löschen
362 dd if=/dev/zero of=$HDD bs=1024k count=1 || die
363 ## hdds partitionieren silent
364 fdisk $HDD < $CONFIGS_TEMPLATE/fdisksettings #1> /dev/null 3> /dev/null || die
365
366 read
367 }
368
369 setup_hdd_format() {
370 mkswap $SWAPHDD || die
371 mke2fs -j -q $BOOTHDD || die
372 mke2fs -j -q $ROOTHDD || die
373 }
374
375 install_mount_rootfs() {
376 swapon $SWAPHDD || die
377 mount $ROOTHDD $INSTALLPATH || die
378 install -d $INSTALLPATH/boot || die
379 mount $BOOTHDD $INSTALLPATH/boot || die
380 cd $INSTALLPATH || die
381 }
382
383 install_system_image() {
384 #tar xvzpf $CDPATH/system/autosta_lx.tar.gz
385 tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH}
386 }
387
388
389 install_kernel_image() {
390 declare -i CPUTYPE=`cat /proc/cpuinfo |grep "cpu family"|cut -d ' ' -f3`
391
392 if [ $CPUTYPE -le 5 ];then
393 #echo -e "\033[1;6m\033[36m""i386 Architektur gefunden.""\033[0m"
394 #echo -e "Installiere i386 Kernel..."
395
396 lastdir="`pwd`"
397
398 mkdir -p $INSTALLPATH/INSTALL/kernel || die
399 cd $INSTALLPATH/INSTALL/kernel || die
400 tar xzpf $CDPATH/kernels/kernel-i386.tar.gz || die
401 source $INSTALLPATH/INSTALL/kernel/kernelversion || die
402
403 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die
404 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die
405 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die
406 cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die
407
408 cd $lastdir || die
409
410 elif [ $CPUTYPE -ge 6 ];then
411 #echo -e "\033[1;6m\033[36m""i686 Architektur gefunden.""\033[0m"
412 #echo -e "Installiere i686 Kernel..."
413
414 lastdir="`pwd`"
415
416 mkdir -p $INSTALLPATH/INSTALL/kernel || die
417 cd $INSTALLPATH/INSTALL/kernel || die
418 tar xzpf $CDPATH/kernels/kernel-i686.tar.gz || die
419 source $INSTALLPATH/INSTALL/kernel/kernelversion || die
420
421 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die
422 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die
423 cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die
424 cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die
425
426 cd $lastdir || die
427 fi
428 }
429
430 install_bootsector() {
431 ### grubconf schreiben
432 source $INSTALLPATH/INSTALL/kernel/kernelversion
433
434 if [ -z $KRNVER ]
435 then
436 KRNVER="AutoSta_LX"
437 fi
438
439 if [ -z $KRNIMG ]
440 then
441 KRNIMG="bzImage"
442 fi
443
444 if [ -z $KRNINITRD ]
445 then
446 KRNINITRD="initrd"
447 fi
448
449 echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die
450 echo -e "timeout 03" >> $INSTALLPATH/boot/grub/grub.conf ||die
451 #no support for splash image in 6.1-r2
452 #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die
453 echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die
454 echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die
455
456 #s3 cards don't support this
457 #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die
458 #that's more safer:
459 echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die
460
461 #not needed without bootsplash support
462 #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die
463
464 ### bootsector schreiben
465 #grub --no-floppy < $CONFIGS_TEMPLATE/grubsettings || die
466 /sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null || die
467 root (hd0,0)
468 setup (hd0)
469 quit
470 EOF
471 }
472
473 install_bootsector_chroot() {
474 ### grubconf schreiben
475 #source $INSTALLPATH/INSTALL/kernel/kernelversion
476 source $INSTALLPATH/boot/kernelversion
477
478 #for alx only
479 if [ -e ${INSTALLPATH}/etc/alx_version ]
480 then
481 OLD_ALXVER="${ALXVER}"
482 source ${INSTALLPATH}/etc/alx_version
483 KRNVER="ALX-${ALXVER}"
484 ALXVER="${OLD_ALXVER}"
485 fi
486
487 if [ -z "$KRNVER" ]
488 then
489 KRNVER="AutoSta_LX"
490 fi
491
492 if [ -z "$KRNIMG" ]
493 then
494 KRNIMG="bzImage"
495 fi
496
497 if [ -z "$KRNINITRD" ]
498 then
499 KRNINITRD="initrd"
500 fi
501
502 echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die
503 echo -e "timeout 03" >> $INSTALLPATH/boot/grub/grub.conf ||die
504
505 #no support for splash image in 6.1-r2
506 #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die
507
508 echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die
509 echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die
510
511 #s3 cards don't support this
512 #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die
513 #that's more safer:
514 echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die
515
516 #not needed without bootsplash support
517 #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die
518
519
520 ### bootsector schreiben chrooted schreiben (gentoo)
521 if [ -f $INSTALLPATH/sbin/grub ]
522 then
523 cat > $INSTALLPATH/root/.bashrc << CHROOTEOF
524 /sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null
525 root (hd0,0)
526 setup (hd0)
527 quit
528 EOF
529 exit 0
530 CHROOTEOF
531 fi
532
533 ### bootsector schreiben chrooted schreiben (lfs/magellan)
534 if [ -f $INSTALLPATH/usr/sbin/grub ]
535 then
536 cat > $INSTALLPATH/root/.bashrc << CHROOTEOF
537 /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null
538 root (hd0,0)
539 setup (hd0)
540 quit
541 EOF
542 exit 0
543 CHROOTEOF
544 fi
545
546 ##enters chroot
547 mount -t proc proc $INSTALLPATH/proc
548 chroot $INSTALLPATH /bin/bash --rcfile /root/.bashrc -i
549 umount $INSTALLPATH/proc
550 rm $INSTALLPATH/root/.bashrc
551 }
552
553 install_alxconfig(){
554 lastdir="`pwd`"
555
556 mkdir -p $INSTALLPATH/opt/alx-config || die
557 cd $INSTALLPATH/opt/alx-config || die
558 tar xzpf $CDPATH/alx-config/alx-config.tar.gz || die
559 chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_functions.sh || die
560 chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_menu.sh || die
561 ln -sf /opt/alx-config/Configurator/config_menu.sh $INSTALLPATH/bin/ALXConfig || die
562
563 cd $lastdir || die
564 }
565
566
567 install_system_settings(){
568 ### schreibe fstab
569 echo -e "$BOOTHDD\t/\text3\tnoatime,noauto\t1 1" > $INSTALLPATH/etc/fstab || die
570 echo -e "$ROOTHDD\t/\text3\tnoatime\t0 0" >> $INSTALLPATH/etc/fstab || die
571 echo -e "$SWAPHDD\tswap\tswap\tpri=1\t0 0" >> $INSTALLPATH/etc/fstab || die
572 echo -e "none\t/proc\tproc\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die
573
574 #deprecated
575 #echo -e "devpts\t/dev/pts\tdevpts\tgid=4,mode=620\t0 0" >> $INSTALLPATH/etc/fstab || die
576
577 echo -e "none\t/dev/shm\ttmpfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die
578 echo -e "none\t/proc/bus/usb\tusbfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die
579 }
580
581 install_hotfixes(){
582 if [ -f $CDPATH/hotfixes/hotfixes.sh ]
583 then
584 dialog_hotfixes
585 sleep1
586 $CDPATH/hotfixes/hotfixes.sh
587 fi
588 }
589
590 install_umount_rootfs() {
591 cd /
592 umount $INSTALLPATH/boot || die
593 umount $INSTALLPATH || die
594 swapoff $SWAPHDD || die
595 }
596
597 install_do_reboot() {
598
599 #only for now later it will be used again
600 #with 6.1-r2 these options are not available
601 #cd /
602 #umount $CDPATH
603 #eject
604 #clear
605
606 reboot
607 }
608
609 #################################################
610 # Install Ablauf Scripte #
611 #################################################
612
613 run_install_normal() {
614 #only for now later it will be used again
615 #with 6.1-r2 only one install method available
616 #dialog_setup_hdd_menu
617 dialog_setup_hdd_found_manuell
618
619 dialog_setup_hdd_partitions_manuell
620 dialog_setup_hdd_format
621 setup_hdd_format > /dev/null
622 install_mount_rootfs
623 (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
624
625 #only for now later it will be used again
626 #with 6.1-r2 variable kernels are not available
627 #dialog_install_kernel_image
628 #install_kernel_image
629
630 dialog_install_bootsector
631 install_bootsector_chroot
632
633 #only for now later it will be used again
634 #with 6.1-r2 highest version of alx-config is already included
635 #dialog_install_alxconfig
636 #sleep 1
637 #install_alxconfig
638
639 dialog_install_settings
640 sleep 1
641 install_system_settings
642 install_hotfixes
643 install_umount_rootfs
644 dialog_install_successful
645 }
646
647 run_install_silent() {
648 echo "starting silent install ..."
649 sleep 1
650 }
651
652 run_install_unattended() {
653 echo "starting unattended install ..."
654 sleep 1
655 }
656
657 if [ "$1" == "unattended" ]
658 then
659 run_install_unattended
660 else
661 dialog_main
662 fi
663
664 exit 0