Changeset 1983 in MondoRescue for branches/2.2.7/mindi/mindi


Ignore:
Timestamp:
Jun 16, 2008, 9:40:42 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Remove aux-tools dir in mindi (either scripts moved or removed)
  • Remove isolinux and syslinux static files from mindi. Now generated
  • Remove lilo support for ia32 now useless in mindi
  • Remoce empty directories in rootfs in mindi
  • Remove HackSyslinuxFile, CopyBootBFile, FindLiloBinary, FindSensibleBootBFile, MakeSyslinuxMessageFile, MakeLiloConfFile, ReplaceIndividualLine in mindi
  • Adds a single MakeBootConfFile function to dynamiclly create needed conf files in mindi
  • Avoids error messages when using only mindi with a non-existant /tmp/mondo-restore.cfg
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.7/mindi/mindi

    r1967 r1983  
    1717
    1818ADDITIONAL_BOOT_PARAMS="devfs=nomount noresume selinux=0 barrier=off"
    19 
    20 #RUN_AFTER_INITIAL_BOOT_PHASE="echo \"Who lives in a pineapple under the sea?\" > /tmp/spongebob.squarepants.txt"
    21     # after booting from image/CD but before
    22     # accessing auxiliary data disks (or the rest of
    23     # the CD), the initscript will run the above command.
    24 
    25 RUN_AFTER_BOOT_PHASE_COMPLETE="ide-opt"
    26     # after the emergency boot process is complete but
    27     # before the init script runs mondorestore, it will
    28     # run this command.
    2919
    3020MINDI_REV=PBREV
     
    113103
    114104
    115 HackSyslinuxFile() {
    116     local incoming
    117     incoming=`ReadLine`
    118     while [ "$incoming" ] ; do
    119         echo -en "$incoming" | sed s/24000/$1/
    120         if [ "`echo "$incoming" | grep append`" ] ; then
    121             echo -en " $ADDITIONAL_BOOT_PARAMS"
    122         fi
    123         echo -en "\n"
    124         incoming=`ReadLine`
    125     done
    126     if [ -e "$MINDI_LIB/memtest.img" ] ; then
    127         echo -en "label memtest\n  kernel memdisk\n  append initrd=memtest.img\n\n"
    128     fi
    129 }
    130 
    131 
    132105Aborted() {
    133106    trap SIGHUP SIGTERM SIGTRAP SIGINT
     
    219192    done
    220193    rm -f $scratchfile
    221 }
    222 
    223 
    224 CopyBootBFile() {
    225     local copy_to copy_from possible_locations liloc
    226     copy_to=$1
    227     copy_from=/boot/boot.b
    228     liloc=`which lilo.real 2>/dev/null`
    229     [ $liloc ] || liloc=`which lilo 2>/dev/null`
    230     if [ $liloc ]; then
    231         if ! [ `strings $liloc | grep "boot\.b"` ]; then
    232             LogIt "boot.b files built into lilo; I'll create a dummy."
    233             > $copy_to
    234             return 0
    235         fi
    236     fi
    237     if [ ! -f "$copy_from" ] ; then
    238         LogIt "OK, you don't have a /boot/boot.b file, which is odd because\n most _good_ Linux distributions come with one, even if it's only a softlink"
    239         copy_from=`grep install= /etc/lilo.conf | grep "\.b" | cut -d'=' -f2`
    240         if [ ! -f "$copy_from" ] ; then
    241             LogIt "Nor can I find it from your /etc/lilo.conf file. This is very odd."
    242             copy_from=`FindSensibleBootBFile`
    243             LogIt "I'm going to use '$copy_from'"
    244         fi
    245     fi
    246     cp -f $copy_from $copy_to 2>> $LOGFILE || LogIt "CBBF -- warning -- cannot find your boot.b file. That's it, I quit... (j/k)"
    247194}
    248195
     
    472419    mkdir -p $bigdir/tmp
    473420    echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
    474     KBDEPTH=0
     421    KBDElabel=memtest\nPTH=0
    475422    AddKeyboardMappingFile $mappath
    476423    echo -e "$DONE"
     
    490437    [ ! -e "$ISOLINUX" ] && Die "Please install isolinux first. If your syslinux RPM doesn't include isolinux, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.com and click on 'Download'"
    491438    echo "Found isolinux.bin at $ISOLINUX" >> $LOGFILE
    492 }
    493 
    494 
    495 FindLiloBinary() {
    496     if which lilo &> /dev/null ; then
    497         if which lilo.real > /dev/null 2> /dev/null ; then
    498             LILO_EXE=lilo.real
    499             LogIt "lilo.real found; will be used instead of lilo (*grumble* *mutter*)"
    500         else
    501             LILO_EXE=lilo
    502         fi
    503         $LILO_EXE -V | grep -F "21.6" > /dev/null && Die "Please upgrade LILO. Your version has a serious bug. If you're not _using_ LILO, fine, uninstall it. :)"
    504     else
    505         LILO_EXE=`which false`
    506     fi
    507 }
    508 
    509 
    510 FindSensibleBootBFile() {
    511     local i out last
    512     out=""
    513     last=""
    514     for i in `find /boot -type f | grep -v chain | grep -v os2 | sort -u` ; do
    515     if [ "`strings $i 2> /dev/null | head -n1`" = "LILO" ] ; then
    516         out="$out $i"
    517         last="$i"
    518     fi
    519     done
    520     echo "$last"
    521439}
    522440
     
    853771ListImagesForUser() {
    854772    local path fname
    855     path=$1
     773    path=$MINDI_CACHE
    856774    echo -en "In the directory '$path' you will find the images:-\n"
    857775    for fname in `ls $path | grep -F mindi-` ; do
     
    13841302
    13851303
    1386 MakeSyslinuxMessageFile() {
    1387     mkdir -p $1
    1388     rmdir $1
    1389     echo -en "  " > $1
    1390     if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
    1391         sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ >> $1.tmp
    1392     else
    1393         sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' '\\r' 'on' 'an' '\/' '`uname -r`' 'on' 'an' '`uname -m`/ >> $1.tmp
    1394     fi
    1395     sed s/%r/"`uname -r`"/ $1.tmp | sed s/%t/"`hostname`"/ > $1
    1396     rm -f $1.tmp
    1397     if [ "$CDRECOVERY" != "yes" ] ; then
    1398         if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
    1399             echo -en "Press <enter> to continue.\n" >> $1
    1400         elif [ ! "$MINDI_TMP" ] ; then
    1401             echo -en "FYI, this is _not_ a Mondo Rescue CD.\n" >> $1
    1402             if [ -e "$MINDI_LIB/memtest.img" ] ; then
    1403                 echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n" >> $1
    1404             fi
    1405         else
    1406             echo -en "$BOOT_MEDIA_MESSAGE" >> $1
    1407         fi
    1408     else
    1409         echo -en " \
    1410 To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
    1411 CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n" >> $1
    1412     fi
    1413 }
    1414 
    1415 
    14161304OfferToMakeBootableISO() {
    14171305    local i old_pwd
     
    14251313    fi
    14261314    rm -Rf $MINDI_TMP/iso
    1427     mkdir -p $MINDI_TMP/iso/{images,archives,isolinux}
    1428     cp -f $1/*.gz $MINDI_TMP/iso/images 2>> $LOGFILE || LogIt "OfferToMakeBootableISO: Cannot copy $1/*.gz to $MINDI_TMP/iso/images"
    1429     old_pwd=`pwd`
    1430     cd $MINDI_TMP/iso
     1315    mkdir -p $MINDI_TMP/iso/{images,archives}
     1316    cp -f $MINDI_CACHE/*.gz $MINDI_TMP/iso/images 2>> $LOGFILE || LogIt "OfferToMakeBootableISO: Cannot copy $MINDI_CACHE/*.gz to $MINDI_TMP/iso/images"
    14311317    echo "mindi_lib = $MINDI_LIB" >> $LOGFILE
    14321318    for i in memdisk memtest.bin memtest.img ; do
    14331319        j=$MINDI_LIB/$i
    1434         k=$MINDI_TMP/iso/isolinux
     1320        k=$MINDI_TMP/iso
    14351321        if [ -e "$j" ] ; then
    14361322            LogIt "Copying $j to $k"
     
    14421328        fi
    14431329    done
    1444     MakeSyslinuxMessageFile $MINDI_TMP/iso/isolinux/message.txt
    1445     cp $kernelpath $MINDI_TMP/iso/isolinux/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/iso/isolinux/vmlinuz). Did you run out of disk space?"
    1446     cp $MINDI_TMP/mindi.rdz $MINDI_TMP/iso/isolinux/initrd.img 2>> $LOGFILE || Die "Cannot copy mindi.rdz ($MINDI_TMP/mindi.rdz) to $MINDI_TMP/iso/isolinux/initrd.img. Did you run out of disk space?"
     1330    MakeMessageFile > $MINDI_TMP/iso/message.txt
     1331    cp $kernelpath $MINDI_TMP/iso/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/iso/vmlinuz). Did you run out of disk space?"
     1332    cp $MINDI_TMP/initrd.img $MINDI_TMP/iso/initrd.img 2>> $LOGFILE || Die "Cannot copy initrd.img ($MINDI_TMP/initrd.img) to $MINDI_TMP/iso/initrd.img. Did you run out of disk space?"
    14471333    if [ _"$MONDO_SHARE" != _"" ]; then
    14481334        cp $kernelpath $MONDO_ROOT/vmlinuz 2>> $LOGFILE || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/vmlinuz). Did you run out of disk space?"
    1449         cp $MINDI_TMP/mindi.rdz $MONDO_ROOT/initrd.img 2>> $LOGFILE || Die "Cannot copy mindi.rdz ($MINDI_TMP/mindi.rdz) to $MONDO_ROOT/initrd.img. Did you run out of disk space?"
    1450     fi
    1451     [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
    1452     cd $MINDI_TMP/iso/isolinux
    1453     cat $iso_cfg_file | HackSyslinuxFile $ramdisk_size $MINDI_TMP/iso > isolinux.cfg || Die "Cannot copy isolinux.cfg to $MINDI_TMP/iso/isolinux - did you run out of disk space?"
    1454     if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
    1455         perl -pi -e 's/interactive/iso/' isolinux.cfg
    1456     fi
     1335        cp $MINDI_TMP/initrd.img $MONDO_ROOT/initrd.img 2>> $LOGFILE || Die "Cannot copy initrd.img ($MINDI_TMP/initrd.img) to $MONDO_ROOT/initrd.img. Did you run out of disk space?"
     1336    fi
     1337    MakeBootConfFile syslinux > $MINDI_TMP/iso/isolinux.cfg
    14571338    if [ "$ARCH" != "ia64" ] ; then
    1458         cp $ISOLINUX isolinux.bin 2> /dev/null || Die "Cannot copy isolinux.bin ($ISOLINUX) to $MINDI_TMP/iso/isolinux - did you run out of disk space?"
    1459         cp $ISOLINUX ../ 2>> $LOGFILE
    1460     fi
     1339        cp $ISOLINUX $MINDI_TMP/iso/isolinux.bin 2> /dev/null || Die "Cannot copy isolinux.bin ($ISOLINUX) to $MINDI_TMP/iso - did you run out of disk space?"
     1340    fi
     1341    old_pwd=`pwd`
    14611342    cd $MINDI_TMP/iso
    14621343    if [ "$ARCH" != "ia64" ] ; then
    14631344        if [ _"$MONDO_SHARE" != _"" ]; then
    1464             cp -f $MINDI_TMP/iso/isolinux/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT 2> /dev/null || Die "Cannot copy core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
    1465             cp -f $MONDO_SHARE/autorun . 2>> $LOGFILE
    1466         fi
    1467         $ISO_CMD -U $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> $MINDI_TMP/mkisofs.log
    1468     else
    1469         $ISO_CMD $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b images/mindi-bootroot.$BOOT_SIZE.img -c isolinux/boot.cat -no-emul-boot . > /dev/null 2> $MINDI_TMP/mkisofs.log
     1345            cp -f $MINDI_TMP/iso/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT 2> /dev/null || Die "Cannot copy core files to ramdisk for boot disk (under $MONDO_ROOT). Did you run out of disk space?"
     1346            cp -f $MONDO_SHARE/autorun $MINDI_TMP/iso 2>> $LOGFILE
     1347        fi
     1348        $ISO_CMD -U $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> $MINDI_TMP/mkisofs.log
     1349    else
     1350        $ISO_CMD $ISO_OPT -V Mindi_Image -o $MINDI_CACHE/mindi.iso -b images/mindi-bootroot.$BOOT_SIZE.img -c images/boot.cat -no-emul-boot . > /dev/null 2> $MINDI_TMP/mkisofs.log
    14701351        rm -f images/mindi-bootroot.$BOOT_SIZE.img
    14711352    fi
     
    15611442    echo -en "."
    15621443    mkdir -p $MINDI_TMP/usb/images
    1563     cp -f $1/*.img $1/*.gz $MINDI_TMP/usb/images 2>> $LOGFILE || LogIt "OfferToMakeBootableUSB: Cannot copy $i to $MINDI_TMP/usb/images"
     1444    cp -f $MINDI_CACHE/*.img $MINDI_CACHE/*.gz $MINDI_TMP/usb/images 2>> $LOGFILE || LogIt "OfferToMakeBootableUSB: Cannot copy $i to $MINDI_TMP/usb/images"
    15641445    echo -en "."
    1565     old_pwd=`pwd`
    1566     cd $MINDI_TMP/usb
    15671446    echo "mindi_lib = $MINDI_LIB" >> $LOGFILE
    15681447    for i in memdisk memtest.bin memtest.img ; do
     
    15761455    done
    15771456    echo -en "."
    1578     MakeSyslinuxMessageFile $MINDI_TMP/usb/message.txt
     1457    MakeMessageFile > $MINDI_TMP/usb/message.txt
    15791458    echo -en "."
    1580     cp $kernelpath $MINDI_TMP/usb/vmlinuz 2> /dev/null || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/usb/syslinux/vmlinuz). Did you run out of disk space?"
     1459    cp $kernelpath $MINDI_TMP/usb/vmlinuz 2> /dev/null || Die "Cannot copy vmlinuz ($kernelpath) to mindi tmp ($MINDI_TMP/usb/vmlinuz). Did you run out of disk space?"
    15811460    echo -en "."
    1582     cp $MINDI_TMP/mindi.rdz $MINDI_TMP/usb/initrd.img 2>> $LOGFILE
     1461    cp $MINDI_TMP/initrd.img $MINDI_TMP/usb/initrd.img 2>> $LOGFILE
    15831462    echo -en "."
    1584     [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
    1585     cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $MINDI_TMP/usb > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to $MINDI_TMP/usb - did you run out of disk space?"
    1586     echo -en "."
    1587     if [ "$NFS_DEV" != "" ] ; then
    1588         perl -pi -e 's/interactive/iso/' syslinux.cfg
    1589     fi
    1590     cd $old_pwd
     1463    MakeBootConfFile syslinux > syslinux.cfg
    15911464    echo -en "."
    15921465    umount $MINDI_TMP/usb
     
    16111484
    16121485MakeMessageFile() {
    1613     if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
    1614         sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/
    1615     else
    1616         sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/
     1486    iss="/dev/null"
     1487    [ -e /etc/issue ] && iss="/etc/issue"
     1488    [ -e /etc/issue.net ] && iss="/etc/issue.net"
     1489    if [ "`grep -Fi "debian" $iss 2> /dev/null`" ] ; then
     1490        sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 $iss` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/%r/"`uname -r`"/ | sed s/%t/"`hostname`"/
     1491    else
     1492        sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" $iss | sed s~/~~ | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" $iss | sed s~/~~ | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/ | sed s/%r/"`uname -r`"/ | sed s/%t/"`hostname`"/
    16171493    fi
    16181494    if [ _"$MONDO_SHARE" != _"" ]; then
     
    16221498            elif [ ! "$MINDI_TMP" ] ; then
    16231499                echo -en "FYI, this is _not_ a Mondo Rescue CD.\n"
     1500                if [ -e "$MINDI_LIB/memtest.img" ] ; then
     1501                 echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n"
     1502                fi
    16241503            else
    16251504                echo -en "$BOOT_MEDIA_MESSAGE"
    16261505            fi
    1627         fi
    1628     fi
    1629     if [ "$CDRECOVERY" = "yes" ] ; then
    1630         echo -en "\
     1506        else
     1507            echo -en "\
    16311508To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
    16321509CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n"
     1510        fi
    16331511    fi
    16341512    echo -en "\n\n\n"
     
    16361514
    16371515
    1638 MakeLiloConfFile() {
     1516MakeBootConfFile() {
    16391517    local options i ooo
    16401518    options=""
    1641 
    1642     if [ "$ARCH" != "ia64" ] ; then
    1643         echo -en "boot=/dev/loop0\ndisk=/dev/loop0\n"
    1644         echo -en "install=/boot.b\nmap=/boot.map\n"
    1645     fi
     1519    # Type of boot file (elilo or syslinux/isolinux)
     1520    type=$1
     1521    if [ "$type" = "elilo" ]; then
     1522        sep="="
     1523    else
     1524        sep=" "
     1525    fi
     1526
     1527    # Generic header for conf file
     1528    if [ "$type" != "elilo" ] ; then
     1529        echo -en "prompt 1\ndisplay message.txt\n"
     1530    else
     1531        echo -en "prompt\n"
     1532    fi
     1533
     1534    # Compute which default option to boot from
    16461535    if [ "$CDRECOVERY" = "yes" ] ; then
    1647         echo -en "default=RESTORE\n"
     1536        echo -en "default${sep}RESTORE\n"
     1537    # In case it's mondoarchive
    16481538    elif [ _"$MONDO_SHARE" != _"" ]; then
    16491539        if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
    1650             echo -en "default=iso\n"
     1540            echo -en "default${sep}iso\n"
    16511541        else
    1652             echo -en "default=interactive\n"
    1653         fi
    1654     else
    1655         echo -en "default=expert\n"
    1656     fi
    1657 
    1658     echo -en "prompt\n"
    1659     if [ "$ARCH" != "ia64" ] ; then
    1660         echo -en "vga=normal\nbackup=/dev/null\nmessage=/message\n"
    1661     fi
     1542            echo -en "default${sep}interactive\n"
     1543        fi
     1544    else
     1545        echo -en "default${sep}expert\n"
     1546    fi
     1547
     1548    # Handle timeout
    16621549    if [ "$CDRECOVERY" != "yes" ] ; then
    1663         echo -en "timeout=300\n"
     1550        echo -en "timeout${sep}300\n"
     1551    else
     1552        echo -en "timeout${sep}10000\n"
    16641553    fi
    16651554    echo -en "\n"
     1555
     1556    # prepare which labels will be generted
    16661557    if [ "$CDRECOVERY" = "yes" ] ; then
    16671558        options="RESTORE expert"
     
    16771568        fi
    16781569    fi
     1570
     1571    # Generate rest of conf file
    16791572    for i in $options ; do
    16801573        ooo=$i
    16811574        [ "$ooo" = "RESTORE" ] && ooo="nuke"
    1682         if [ "$ARCH" = "ia64" ] ; then
    1683             rootpart="root=/dev/ram0\n\t"
     1575        if [ "$type" = "elilo" ]; then
     1576            outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/initrd.img\n\troot=/dev/ram0 append=\" rw ramdisk_size=$ramdisk_size $ooo_mode $ADDITIONAL_BOOT_PARAMS \"\n"
    16841577        else
    1685             rootpart=""
    1686         fi
    1687         outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/mindi.rdz\n\t${rootpart}append=\" rw ramdisk=$ramdisksize ramdisk_size=$ramdisksize maxcpus=1 $ooo_mode $ADDITIONAL_BOOT_PARAMS"
    1688    
    1689         outstr=$outstr" $ooo_mode"
    1690         outstr=$outstr"\"\n"
     1578            outstr="label $i\n\tkernel /vmlinuz\n\tappend initrd=/initrd.img root=/dev/ram0 rw ramdisk_size=$ramdisk_size ${ooo}_mode $ADDITIONAL_BOOT_PARAMS\n"
     1579        fi
    16911580        echo -en "$outstr"
    16921581    done
     1582
     1583    if [ -e "$MINDI_LIB/memtest.img" ] ; then
     1584        if [ "$type" = "elilo" ]; then
     1585            echo -en "image=/memtest.bin\n\tlabel=memtest\n"
     1586            echo -en "image=/memdisk\n\tlabel=memtest\nappend=\"initrd=memtest.img\"\n"
     1587        else
     1588            echo -en "label memtest\n\tkernel /memtest.bin\n"
     1589            echo -en "label=memtest\n\tkernel /memdisk\nappend initrd=memtest.img\n"
     1590        fi
     1591    fi
    16931592}
    16941593
    16951594
    16961595PrepareBootDiskImage_LILO() {
    1697     local imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
    1698     imagesdir=$1
    1699     kernelpath=$2
    1700     ramdisksize=$3
     1596    local imagesdir dev imagefile mountpoint fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
     1597    imagesdir=$MINDI_CACHE
     1598    kernelpath=$1
    17011599
    17021600    retval=0
    17031601    [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    17041602    echo -en "Making "$BOOT_SIZE"KB boot disk..."
    1705     TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/mindi.rdz $ramdisksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
     1603    TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?"
    17061604    echo -en "..."
    17071605    imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img
     
    17091607    mkdir -p $mountpoint
    17101608    dd if=/dev/zero of=$imagefile bs=1k count=$BOOT_SIZE &> /dev/null || Die "Cannot dd blank file"
    1711     if [ "$ARCH" = "ia64" ] ; then
    1712         mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE
    1713         t=vfat
    1714     else
    1715         echo "Creating ext2 filesystem on $imagefile" >> $LOGFILE
    1716         mke2fs -N 26 -m 0 -F $imagefile &> /dev/null || Die "Unable to create an ext2 file system on $imagefile"
    1717         t=ext2
    1718     fi
    1719     mount -t $t -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)"
     1609    mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE
     1610    mount -t vfat -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)"
    17201611    # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
    17211612    mkdir -p $mountpoint/etc
    1722     if [ "$ARCH" != "ia64" ] ; then
    1723         liloconf=$mountpoint/etc/lilo.conf
    1724     else
    1725         liloconf=$mountpoint/elilo.conf
    1726     fi
    1727     old_pwd=`pwd`
    1728     cd $mountpoint
    1729     if [ "$ARCH" != "ia64" ] ; then
    1730         tar -zxf $MINDI_LIB/dev.tgz || LogIt "Cannot untar dev.tgz"
    1731     fi
    1732     cd $old_pwd
    1733     # BERLIOS : Useless and generating errors on CentOS ? (losetup miss a param)
    1734     #losetup /dev/loop0 > /dev/null 2> /dev/null
    1735     #[ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing   'losetup /dev/loop0 -d'.\nReboot if necessary."
    1736     CopyBootBFile $mountpoint/boot.b
    1737 
    1738     MakeLiloConfFile > $liloconf
     1613    liloconf=$mountpoint/elilo.conf
     1614
     1615    MakeBootConfFile elilo > $liloconf
    17391616
    17401617    # Copy it so that CD-ROM menu entry is satisfied
    1741     if [ "$ARCH" = "ia64" ] ; then
    1742         mountefi=0
    1743         df -T | grep /boot/efi | grep -q vfat
     1618    mountefi=0
     1619    df -T | grep /boot/efi | grep -q vfat
     1620    if [ $? -ne 0 ]; then
     1621        mount /boot/efi
    17441622        if [ $? -ne 0 ]; then
    1745             mount /boot/efi
    1746             if [ $? -ne 0 ]; then
    1747                 echo "You have to mount your EFI partition when using mindi"
    1748                 MindiExit -1
    1749             fi
    1750             mountefi=1
    1751         fi
    1752         el=`find /boot/efi -name elilo.efi`
    1753         cp $el $mountpoint
    1754         cp $liloconf $mountpoint
    1755         if [ $mountefi -eq 1 ]; then
    1756             umount /boot/efi 2>&1 > /dev/null
    1757         fi
    1758     fi
    1759 
    1760     echo "Copying $MINDI_TMP/mindi.rdz to $mountpoint..." >> $LOGFILE
    1761     cp -f $MINDI_TMP/mindi.rdz $mountpoint 2>> $LOGFILE
     1623            echo "You have to mount your EFI partition when using mindi"
     1624            MindiExit -1
     1625        fi
     1626        mountefi=1
     1627    fi
     1628    el=`find /boot/efi -name elilo.efi`
     1629    cp $el $mountpoint
     1630    cp $liloconf $mountpoint
     1631    if [ $mountefi -eq 1 ]; then
     1632        umount /boot/efi 2>&1 > /dev/null
     1633    fi
     1634
     1635    echo "Copying $MINDI_TMP/initrd.img to $mountpoint..." >> $LOGFILE
     1636    cp -f $MINDI_TMP/initrd.img $mountpoint 2>> $LOGFILE
    17621637    if [ "$?" -ne "0" ] ; then
    1763         LogIt "Failed to copy $MINDI_TMP/mindi.rdz to $mountpoint"
     1638        LogIt "Failed to copy $MINDI_TMP/initrd.img to $mountpoint"
    17641639        cat $MINDI_TMP/mtpt.$$ >> $LOGFILE
    17651640        LogIt "Please unload some of your modules and try again."
    17661641        rm -f $MINDI_TMP/mtpt.$$
    1767         LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
     1642        LogIt "Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)"
    17681643        retval=$(($retval+1))
    17691644    fi
    1770     MakeMessageFile > $mountpoint/message
     1645    MakeMessageFile > $mountpoint/message.txt
    17711646
    17721647    mkdir -p $mountpoint/tmp
    1773     cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
    1774     if [ -e "$MINDI_LIB/memtest.img" ] ; then
    1775         echo -en "image=/memtest.bin\nlabel=memtest\nn" >> $liloconf
    1776         echo -en "image=/memdisk\nlabel=memtest\nappend=\"initrd=memtest.img\"\n" >> $liloconf
    1777 #        echo "Yep, this is a multi-function CD" > $mountpoint/MULTIFUNC
     1648    if [ -f "$MINDI_TMP/mondo-restore.cfg" ]; then
     1649        cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp
    17781650    fi
    17791651
     
    18041676    rm -f $mountpoint/zero
    18051677    [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE
    1806     if [ ! "$KERN_DISK_MADE" ] ; then
    1807         if [ "$ARCH" != "ia64" ] ; then
    1808             $LILO_EXE $LILO_OPTIONS -r $mountpoint >> $LOGFILE 2>> $LOGFILE
    1809         else
    1810             /bin/true
    1811         fi
    1812     else
     1678    if [ "$KERN_DISK_MADE" ] ; then
    18131679        echo "Not running LILO. It's not that kind of disk." >> $LOGFILE
    18141680    fi
    18151681
    1816     # BERLIOS  does not test necessarily what it expects
    1817     if [ $? -ne "0" ] ; then
    1818         if [ "`grep -F "/tmp/dev.0" $LOGFILE`" ] ; then
    1819             LogIt "The '/tmp/dev.0' error is NOT Mindi's fault. It is LILO's."
    1820             LogIt "Please reboot your PC as a workaround."
    1821             Die "LILO sneezed and Mindi caught a cold. Please read the README / FAQ."
    1822         fi
    1823         echo "$LILO_EXE -r $mountpoint ...failed."
    1824         echo -en "Press ENTER to continue."; read line
    1825         LogIt "Cannot run lilo on $mountpoint\nPlease upgrade/downgrade your version of LILO. It has a bug."
    1826         retval=$(($retval+1))
    1827     fi
    18281682    cp -f $liloconf $MINDI_TMP/lilo.conf 2>> $LOGFILE
    1829     if [ "$ARCH" = "ia64" ] ; then
    1830         cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE
    1831     fi
     1683    cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE
    18321684    umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    18331685    echo -en "..."
     
    18491701
    18501702PrepareBootDiskImage_SYSLINUX() {
    1851     local imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
    1852     imagesdir=$1
    1853     kernelpath=$2
    1854     ramdisksize=$3
     1703    local imagesdir dev imagefile mountpoint fname i kernelpath cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
     1704    imagesdir=$MINDI_CACHE
     1705    kernelpath=$1
    18551706    do_boot_root_thingy=""
    18561707    local retval old_pwd
     
    18591710    [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    18601711    echo -en "Making "$BOOT_SIZE"KB boot disk..."
    1861     TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/mindi.rdz $ramdisksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
     1712    TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/initrd.img `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into initrd.img; are you SURE your kernel supports loopfs?"
    18621713    echo -en "..."
    18631714    imagefile=$imagesdir/mindi-bootroot.$BOOT_SIZE.img
     
    18721723
    18731724    # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
    1874     old_pwd=`pwd`
    1875     MakeSyslinuxMessageFile $mountpoint/message.txt
    1876     cd $mountpoint
    1877     [ -e "$sys_cfg_file" ] || Die "Obi Wan, word up?"
    1878     cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $mountpoint > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to tmp_root"
    1879     if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
    1880         perl -pi -e 's/interactive/iso/' syslinux.cfg
    1881     fi
    1882     cd $old_pwd
    1883     echo "Copying $MINDI_TMP/mindi.rdz to $mountpoint/initrd.img..." >> $LOGFILE
    1884     cp -f $MINDI_TMP/mindi.rdz $mountpoint/initrd.img 2>> $LOGFILE
     1725    MakeMessageFile > $mountpoint/message.txt
     1726    MakeBootConfFile syslinux > $mountpoint/syslinux.cfg
     1727    echo "Copying $MINDI_TMP/initrd.img to $mountpoint/initrd.img..." >> $LOGFILE
     1728    cp -f $MINDI_TMP/initrd.img $mountpoint/initrd.img 2>> $LOGFILE
    18851729    if [ "$?" -ne "0" ] ; then
    1886         LogIt "Failed to copy $MINDI_TMP/mindi.rdz to $mountpoint"
     1730        LogIt "Failed to copy $MINDI_TMP/initrd.img to $mountpoint"
    18871731        cat $MINDI_TMP/mtpt.$$ >> $LOGFILE
    18881732        LogIt "Please unload some of your modules and try again."
    18891733        rm -f $MINDI_TMP/mtpt.$$
    1890         LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
     1734        LogIt "Cannot incorporate initrd.img in bootdisk (kernel / modules too big?)"
    18911735        retval=$(($retval+1))
    18921736    fi
    18931737
    18941738    mkdir -p $mountpoint/tmp
    1895     cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
     1739    if [ -f "$MINDI_TMP/mondo-restore.cfg" ]; then
     1740        cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp
     1741    fi
    18961742
    18971743    # copy the kernel across
     
    19461792    local needlist bigdir diskdir imagesdir res i j k old_pwd lines lfiles
    19471793
    1948     imagesdir=$1
     1794    imagesdir=$MINDI_CACHE
    19491795    rm -f $imagesdir/mindi.iso
    19501796    needlist=$MINDI_TMP/what-we-need.txt
    19511797    bigdir=$MINDI_TMP/bigdir
    19521798    mkdir -p $bigdir/usr/bin
     1799    mkdir -p $bigdir/usr/sbin
    19531800
    19541801    lfiles="$DEPLIST_FILE"
     
    20231870    cd $bigdir
    20241871
    2025     [ -e "$MINDI_LIB/aux-tools" ] || Die "aux-tools not found in Mindi's home dir. Do you have multiple copies of Mindi lying around? Please delete them. No, don't e-mail me and ask how. ;) Use 'rm'."
    2026     cp -Rdf $MINDI_LIB/aux-tools/* . 2>> $LOGFILE || LogIt "WARNING - error occurred while unzipping aux-tools"
    2027     if [ -e "$MINDI_LIB/x11-tools.tgz" ] ; then
    2028         tar -zxf $MINDI_LIB/x11-tools.tgz 2>> $LOGFILE || LogIt "WARNING - error occurred while unzipping x11-tools.tgz"
     1872    # Get terminfo content
     1873    ti="usr/share/terminfo/l"
     1874    if [ -d /$ti ]; then
     1875        mkdir -p $ti
     1876        cp -Rdf /$ti/* $ti 2>> $LOGFILE || LogIt "WARNING - error occurred while copying terminfo"
    20291877    fi
    20301878    if [ -e "$MONDO_SHARE/restore-scripts" ]; then
     
    20321880        [ "$?" -ne "0" ] && [ _"$MONDO_SHARE" != _"" ] && Die "Cannot find/install $MONDO_SHARE/restore-scripts"
    20331881    fi
    2034     #[ -d "/lib/dev-state" ] && cp --parents -pRdf /lib/dev-state . 2>> $LOGFILE
    20351882    [ -d "/lib/dev-state" ] && tar cf - /lib/dev-state 2>> $LOGFILE | tar xf -
    20361883    cd $old_pwd
     
    21111958    done
    21121959    echo "$incoming"
    2113 }
    2114 
    2115 
    2116 ReplaceIndividualLine() {
    2117     local orig_file new_file lino newstring lines_total lines_remaining
    2118 
    2119     orig_file=$1.orig
    2120     mv -f $1 $orig_file || Die "Cannot move $1 to $orig_file"
    2121     new_file=$1
    2122     lino=$2
    2123     newstring="$3"
    2124     if [ "$lino" = "" ] || [ "$lino" -lt "1" ] ; then
    2125         echo "Can't find string" >> $LOGFILE
    2126         return 1
    2127     fi
    2128     lines_total=`wc -l $orig_file | $AWK '{print $1;}'`
    2129     lines_remaining=$(($lines_total-$lino))
    2130     head -n$(($lino-1)) $orig_file > $new_file
    2131     echo "$newstring" >> $new_file
    2132     echo "# The above line was added by Mindi, at the user's instruction" >> $new_file
    2133     tail -n$lines_remaining $orig_file >> $new_file
    2134     echo "Replace line $lino of $new_file with user-specified line, '$newstring'" >> $LOGFILE
    2135     [ -x "$orig_file" ] && chmod +x $new_file
    2136     rm -f $orig_file
    2137     return 0
    21381960}
    21391961
     
    23062128
    23072129TurnTgzIntoRdz() {
    2308     local tgz_dir_fname rdz_fname ramdisksize tempfile mountpoint old_pwd nodes kernelsize maxsize res currsize not_copied j k s w needed_modules_path
     2130    local tgz_dir_fname rdz_fname tempfile mountpoint old_pwd nodes kernelsize maxsize res currsize not_copied j k s w needed_modules_path
    23092131
    23102132    tgz_dir_fname=$1
    23112133    rdz_fname=$2
    2312     ramdisksize=$3
    2313     kernelsize=$4
     2134    kernelsize=$3
    23142135    maxsize=$(($BOOT_SIZE-$kernelsize))
    23152136    maxsize=$(($maxsize*2)); # to allow for compression of 50%
     
    24252246        mkdir -p mnt/$w
    24262247    done
    2427     #if [ "$RUN_AFTER_INITIAL_BOOT_PHASE" ] ; then
    2428         #ReplaceIndividualLine sbin/init `grep -n "#WHOLIVESINAPINEAPPLEUNDERTHESEA#" sbin/init | cut -d':' -f1` "$RUN_AFTER_INITIAL_BOOT_PHASE"
    2429     #fi
    2430     if [ "$RUN_AFTER_BOOT_PHASE_COMPLETE" ] ; then
    2431         ReplaceIndividualLine sbin/init `grep -n "#ABSORBENTANDYELLOWANDPOROUSISHE#" sbin/init | cut -d':' -f1` "$RUN_AFTER_BOOT_PHASE_COMPLETE"
    2432     fi
    24332248
    24342249    tar cf - /dev/fd0*[1,2][4,7,8]* 2> /dev/null | tar xf -
     
    26662481else
    26672482    FindIsolinuxBinary
    2668     FindLiloBinary
    26692483fi
    26702484trap "Aborted" SIGTERM
     
    28942708fi
    28952709[ "$CDRECOVERY" = "yes" ] || CDRECOVERY=no
    2896 if [ "$CDRECOVERY" = "yes" ] ; then
    2897     iso_cfg_file=$MINDI_LIB/isolinux-H.cfg
    2898     sys_cfg_file=$MINDI_LIB/syslinux-H.cfg
    2899 else
    2900     iso_cfg_file=$MINDI_LIB/isolinux.cfg
    2901     sys_cfg_file=$MINDI_LIB/syslinux.cfg
    2902 fi
    2903 
    2904 [ -e "$iso_cfg_file" ] || Die "Cannot find $iso_cfg_file"
     2710
    29052711if [ _"$MONDO_SHARE" = _"" ]; then
    29062712    LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION"
     
    29652771        YOUR_KERNEL_SUCKS="That's why you're using mine, dude. :-)"
    29662772    fi
    2967 fi
    2968 if [ _"$MONDO_SHARE" = _"" ] && [ "$ARCH" != "ia64" ]; then
    2969     USE_LILO=no
    29702773fi
    29712774if [ "$YOUR_KERNEL_SUCKS" != "" ] || [ "$kernelpath" = "" ] || [ "$kernelpath" = "SUCKS" ] || [ "$kernelpath" = "FAILSAFE" ] ; then
     
    30022805[ "$YOUR_KERNEL_SUCKS" ] && [ ! "$FAILSAFE_KVER" ] && Die "Please install mindi-kernel package. You need it.\nGo to http://www.mondorescue.org and download it, then install it."
    30032806
    3004 PrepareDataDiskImages $MINDI_CACHE
     2807PrepareDataDiskImages
     2808
    30052809ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
    30062810rds=$(($ramdisk_size-$((ramdisk_size%4096))))
    3007 ramdisk_size=$rds
     2811export ramdisk_size=$rds
    30082812
    30092813echo "Ramdisk will be $ramdisk_size KB" >> $LOGFILE
    30102814if [ "$ARCH" = "ia64" ] ; then
    3011     PrepareBootDiskImage_LILO $MINDI_CACHE $kernelpath $ramdisk_size || Die "Failed to create ia64 image disk image."
     2815    PrepareBootDiskImage_LILO $kernelpath || Die "Failed to create ia64 image disk image."
    30122816else
    3013     if [ "$USE_LILO" = "yes" ] ; then
    3014         PrepareBootDiskImage_LILO $MINDI_CACHE $kernelpath $ramdisk_size || Die "Failed to create $BOOT_SIZE MB disk image."
    3015     else
    3016         PrepareBootDiskImage_SYSLINUX $MINDI_CACHE $kernelpath $ramdisk_size || Die "Failed to create $BOOT_SIZE MB disk image."
    3017     fi
     2817    PrepareBootDiskImage_SYSLINUX $kernelpath || Die "Failed to create $ramdisk_size MB disk image."
    30182818fi
    30192819
     
    30222822
    30232823if [ _"$MONDO_SHARE" = _"" ]; then
    3024     ListImagesForUser $MINDI_CACHE
    3025     OfferToMakeBootableISO $MINDI_CACHE
     2824    ListImagesForUser
     2825    OfferToMakeBootableISO
    30262826    if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ]; then
    3027         OfferToMakeBootableUSB $MINDI_CACHE
     2827        OfferToMakeBootableUSB
    30282828    fi
    30292829    LogIt "Finished."
     
    30312831    rm -f $MINDI_CACHE/{*img,*iso}
    30322832    if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ "$USBDEVICE" != "" ]; then
    3033         OfferToMakeBootableUSB $MINDI_CACHE
    3034     fi
    3035     OfferToMakeBootableISO $MINDI_CACHE
     2833        OfferToMakeBootableUSB
     2834    fi
     2835    OfferToMakeBootableISO
    30362836    if [ -e "$MINDI_CACHE/all.tar.gz" ] ; then
    30372837        cp -f $MINDI_CACHE/all.tar.gz $MINDI_TMP/ 2>> $LOGFILE
     
    30402840    fi
    30412841elif [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ "$USBDEVICE" != "" ]; then
    3042     OfferToMakeBootableUSB $MINDI_CACHE
     2842    OfferToMakeBootableUSB
    30432843else
    3044     OfferToMakeBootableISO $MINDI_CACHE
     2844    OfferToMakeBootableISO
    30452845fi
    30462846# cleanup
Note: See TracChangeset for help on using the changeset viewer.