Magellan Linux

Diff of /trunk/installer-simple/bin/installer.sh.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2443 by niro, Tue Jan 7 14:50:35 2014 UTC revision 2890 by niro, Fri Jul 31 11:11:58 2015 UTC
# Line 7  Line 7 
7  # Niels Rogalla <niro@magellan-linux.de>  # Niels Rogalla <niro@magellan-linux.de>
8  #  #
9    
10  # ignore the environment  # setup locales
11  LC_ALL=C  TEXTDOMAIN=installer
12    
13  # include dir  # include dir
14  INSTALLER_LIBDIR="%LIBDIR%"  INSTALLER_LIBDIR="%LIBDIR%"
15    
# Line 39  do Line 40  do
40   fi   fi
41  done  done
42    
 # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !  
 # -> now in images.conf  
 CDIMAGENAME=""  
 TOTALLINES=""  
 CURRENTLINE=0  
 if [ -e /mnt/cdrom/system/images.conf ]  
 then  
  source /mnt/cdrom/system/images.conf  
  # check if all required variables are set  
  [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in /mnt/cdrom/system/images.conf"  
  [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in /mnt/cdrom/system/images.conf"  
 else  
  die "/mnt/cdrom/system/images.conf not found"  
 fi  
   
43  ### System/Config Version  ### System/Config Version
44  VERSION="%VERSIONTAG%"  VERSION="%VERSIONTAG%"
45  TITLE="${DEFAULT_TITLE} - ${VERSION}"  TITLE="${DEFAULT_TITLE} - ${VERSION}"
46    
47    # initialize global variables so they are exportable
48  # some sane defaults  # some sane defaults
49  CDROOT="${DEFAULT_CDROOT}"  LIVEROOT="${DEFAULT_LIVEROOT}"
50    IMAGEROOT="${DEFAULT_IMAGEROOT}"
51  INSTALLROOT="${DEFAULT_INSTALLROOT}"  INSTALLROOT="${DEFAULT_INSTALLROOT}"
52  KERNELPKG="${DEFAULT_KERNELPKG}"  KERNELPKG="${DEFAULT_KERNELPKG}"
53  KERNELOPTS="${DEFAULT_KERNELOPTS}"  KERNELOPTS="${DEFAULT_KERNELOPTS}"
# Line 69  FDISKPARTIONBELOW256MB=0 Line 57  FDISKPARTIONBELOW256MB=0
57  SPECIALDEVICE=""  SPECIALDEVICE=""
58  FORMFACTOR="${DEFAULT_FORMFACTOR}"  FORMFACTOR="${DEFAULT_FORMFACTOR}"
59  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"
60    FLASHDISK=0
61    
62  #################################################  # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
63  #  DIALOG BOXEN #  # -> now in images.conf
64  #################################################  CDIMAGENAME=""
65    TOTALLINES=""
66    CURRENTLINE=0
67    if [ -e ${IMAGEROOT}/images.conf ]
68    then
69     source ${IMAGEROOT}/images.conf
70     # check if all required variables are set
71     [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf"
72     [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf"
73    else
74     die "${IMAGEROOT}/images.conf not found"
75    fi
76    
77    ### helper scripts ###
78    
79  trap_exit()  trap_exit()
80  {  {
# Line 81  trap_exit() Line 83  trap_exit()
83   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys
84   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot
85   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}
86     [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD}
87    
88   echo $"Installation aborted."   echo $"Installation aborted."
89   exit 1   exit 1
90  }  }
91    
92  dialog_die()  install_meter()
 {  
  ERROR="$1"  
  RETVAL="$?"  
  dialog_install_failure  
  exit 1  
 }  
   
 dialog_warning()  
 {  
  local retval  
   
  yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"  
  retval=$?  
  if [[ ${retval} -eq 1 ]]  
  then  
  clear  
  echo $"The process was aborted."  
  exit 1  
  fi  
 }  
   
 dialog_setup_hdd_info()  
 {  
  local SHDD="${HDD//\/dev\/}"  
   
  messagebox -h $"[ Harddrive partitioning ]" \  
  $"\nPlease create 1 partition.\n\n\[ \Z3${SHDD}1\Zn ] type: \Z3linux\Zn with the whole diskspace\n\Please mark ${SHDD}1 \Z3bootable\Zn."  
 }  
   
 dialog_setup_hdd_info_auto()  
93  {  {
94   local SHDD="${HDD//\/dev\/}"   while [[ ${CURRENTLINE} != ${TOTALLINES} ]]
95     do
96   messagebox -h $"[ Harddrive partitioning ]" \   CURRENTLINE=$(grep -c . /tmp/install.log)
97   $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"   PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))
98     echo ${PERCENT}
99     sleep 1
100     done
101     rm -f /tmp/install.log
102     return 0
103  }  }
104    
105  dialog_setup_system_menu()  mount_rootfs()
106  {  {
  local mode  
107   local retval   local retval
108    
109   mode=$(menubox -h $"[ Harddrive partitioning ]" $"\nSelect an installation mode" \   if [[ -n ${SWAPHDD} ]]
  $"1:Automatic setup (recommended)" \  
  ":" \  
  $":\Z1Expert modes:\Zn" \  
  $"2:Common IDE-disk (manual setup)")  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
110   then   then
111   case "${mode}" in   swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'"
  "1") run_install_auto ;;  
  "2") run_install_normal ;;  
  "") dialog_setup_system_menu;;  
  esac  
112   fi   fi
 }  
   
 dialog_hardware_detection()  
 {  
  local message  
   
  run_hardware_detection_disks  
113    
114   message+=$"Harddrives:\n"   if [[ -n ${ROOTHDD} ]]
   
  if [[ ! -z ${ALL_DISKS} ]]  
115   then   then
116   for i in ${ALL_DISKS}   if is_mounted --location "${INSTALLROOT}"
117   do   then
118   message+="\Z3${i}\Zn "   echo $"${INSTALLROOT} already mounted" >&2
119   done   else
120   message+="\n"   mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"
121     fi
122   fi   fi
123    
124   if [[ ! -z ${ALL_CDROMS} ]]   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot
  then  
  message+="\n"  
  message+=$"Optical disk drives:\n"  
  for i in ${ALL_CDROMS}  
  do  
  message+="\Z3${i}\Zn"  
  done  
  message+="\n"  
  fi  
125    
126   # other devices   if [[ -n ${BOOTHDD} ]]
  run_hardware_detection  
  case "${SPECIALDEVICE}" in  
  zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;  
  rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;  
  maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;  
  *) message+=$"\n \\ZnCommon device detected.\Zn" ;;  
  esac  
  if [[ ${FORMFACTOR} = laptop ]]  
127   then   then
128   message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving  mode.\Zn"   if is_mounted --location "${INSTALLROOT}"/boot
  fi  
   
  messagebox -y 15 -h $"Detected hardware:" "${message}"  
 }  
   
 dialog_setup_hdd_partitions_manual()  
 {  
  local i  
  local retval  
   
  if [[ -z ${ALL_DISKS} ]]  
  then  
  dialog_no_harddrive_found  
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
129   then   then
130   dialog_setup_hdd_info   echo $"${INSTALLROOT}/boot already mounted" >&2
131   setup_hdd_partitions_manual   else
132     mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'"
133   fi   fi
134   fi   fi
135  }  }
136    
137  dialog_setup_hdd_partitions_auto()  umount_rootfs()
138  {  {
139   local i   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot
140   local retval   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}
141    
142   if [[ -z ${ALL_DISKS} ]]   if [[ -n ${SWAPHDD} ]]
143   then   then
144   dialog_no_harddrive_found   swapoff ${SWAPHDD} || die
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
  then  
  dialog_setup_hdd_info_auto  
  dialog_setup_hdd_create_partitions  
  setup_hdd_partitions_auto  
  fi  
145   fi   fi
146  }  }
147    
148  install_meter()  install_do_reboot()
 {  
  while [[ ${CURRENTLINE} != ${TOTALLINES} ]]  
  do  
  CURRENTLINE=$(grep -c . /tmp/install.log)  
  PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))  
  echo ${PERCENT}  
  sleep 1  
  done  
  rm -f /tmp/install.log  
  return 0  
 }  
   
 dialog_main()  
149  {  {
150   local method=0   reboot
  local retval  
   
  while [[ ${method} -le 2 ]]  
  do  
  method=$(menubox $"Configuration:" \  
  $"1:Install system" \  
  $"2:Show detected harddrives" \  
  $"3:Exit and reboot" \  
  $"4:Exit and drop into a shell")  
  retval=$?  
  [[ ${retval} -eq 1 ]] && exit 1  
  if [[ ${retval} -eq 0 ]]  
  then  
  case ${method} in  
  "1") dialog_setup_system_menu ;;  
  "2") dialog_hardware_detection ;;  
  "3") install_do_reboot ;;  
  "4") /bin/bash --login -i ;;  
  esac  
  fi  
  done  
151  }  }
152    
 #################################################  
 # Install Komandos #  
 #################################################  
153  run_hardware_detection()  run_hardware_detection()
154  {  {
155   local hwinfo   local hwinfo
156    
157   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
158    
159   ## check for special devices/clients:   # check for special devices/clients:
160   ## if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd   # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd
161   #local removable=0   local removable=0
162   #if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
163   #then   then
164   #for i in /sys/block/[hs]d*/removable   for i in /sys/block/[hs]d*/removable
165   #do   do
166   #if [[ $(< ${i}) = 1 ]]   if [[ $(< ${i}) = 1 ]]
167   #then   then
168   #removable=1   removable=1
169   #fi   # we assume that all removable disks are flash disks on a zotac
170   #done   export FLASHDISK=1
171   ## smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card'   fi
172     done
173   ## only add this for grub legacy, grub2 detect these settings on its own   # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card'
174   #export GRUBLEGACYOPTS="rootdelay=8"  
175   ## there are to zotac types in the wild, nvidia based gfx and intel   # only add this for grub legacy, grub2 detect these settings on its own
176   #if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]   export GRUBLEGACYOPTS="rootdelay=8"
177   #then   # there are to zotac types in the wild, nvidia based gfx and intel
178   #export SPECIALDEVICE="zotac_nvidia"   if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
179   #else   then
180   #export SPECIALDEVICE="zotac_intel"   export SPECIALDEVICE="zotac_nvidia"
181   #fi   else
182   #fi   export SPECIALDEVICE="zotac_intel"
183     fi
184     fi
185    
186   # check for special devices/clients:   # check for special devices/clients:
187   # if a rangee and disk ist smaller then 256mb move partion one block further ahead   # if a rangee and disk ist smaller then 256mb move partion one block further ahead
# Line 340  run_hardware_detection_disks() Line 217  run_hardware_detection_disks()
217   # all disks but exclude ramdisks   # all disks but exclude ramdisks
218   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')
219   # remove the boot device from ALL_DISKS if it was an usbstick   # remove the boot device from ALL_DISKS if it was an usbstick
220   if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]   if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
221   then   then
222   bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')"   bootdev=$(grep "[[:space:]]${LIVEROOT}[[:space:]]" /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')
223   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
224   fi   fi
225   export ALL_CDROMS="$(get_hwinfo cdrom)"   export ALL_CDROMS="$(get_hwinfo cdrom)"
226  }  }
227    
228  hdd_size_below_256mb()  setup_hdd_partitions()
229  {  {
  local hdd="$1"  
  local size  
  local retval  
  [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"  
   
  size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')  
  if [[ ${size} -le 257000000 ]]  
  then  
  retval="0"  
  else  
  retval="1"  
  fi  
   
  return "${retval}"  
 }  
   
 setup_hdd_partitions_auto()  
 {  
  ROOTHDD="${HDD}1"  
   
230   # sanity check - should not happen   # sanity check - should not happen
231   if is_mounted --device "${ROOTHDD}"   if is_mounted --device "${ROOTHDD}"
232   then   then
233   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2
234   umount "${ROOTHDD}"   umount "${ROOTHDD}"
235   fi   fi
236     if [[ -n ${BOOTHDD} ]]
  # run this only if FDISKPARTITIONBELOW256MB is not already 1  
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
237   then   then
238   if hdd_size_below_256mb ${HDD}   if is_mounted --device "${BOOTHDD}"
239   then   then
240   FDISKPARTIONBELOW256MB=1   echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2
241   else   umount "${BOOTHDD}"
  FDISKPARTIONBELOW256MB=0  
242   fi   fi
243   fi   fi
244    
245   ## delete disk   if [[ ${INSTALL_METHOD} = auto ]]
  dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die  
   
  if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]  
246   then   then
247   ## setup one bootable partition   # run this only if FDISKPARTITIONBELOW256MB is not already 1
248   #1. n= new disk   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
249   #2. p= primary disk   then
250   #3. 1= first partition   if device_minimum_size "${HDD}" 256
251   #4. 2= default sector start // small disk needs more space for grub2 mbr sector   then
252   #5. ''= defaul sector end   FDISKPARTIONBELOW256MB=1
253   #6. a= bootable flag   else
254   #7. 1= boot flag for partition 1   FDISKPARTIONBELOW256MB=0
255   #8. w= write/quit   fi
256   fdisk ${HDD} &> /dev/null << EOF   fi
257    
258     ## delete disk
259     dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die
260    
261     if [[ ${FLASHDISK} = 1 ]]
262     then
263     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
264     then
265     ## setup one bootable partition
266     # 1. n= new disk
267     # 2. p= primary disk
268     # 3. 1= first partition
269     # 4. 2= default sector start // small disk needs more space for grub2 mbr sector
270     # 5. ''= defaul sector end
271     # 6. a= bootable flag
272     # 7. 1= boot flag for partition 1
273     # 8. n= new disk
274     #10. p= primary disk
275     #11. 2= second partition
276     #12. ''= default sector start
277     #13. ''= defaul sector end
278     #14. w= write/quit
279     fdisk ${HDD} &> /dev/null << EOF
280  n  n
281  p  p
282  1  1
283  2  2
284    +50M
285  a  a
286  1  1
287    n
288    p
289    2
290    
291    
292  w  w
293  EOF  EOF
294   else   else
295   ## setup one bootable partition   ## setup one bootable partition
296   #1. n= new disk   # 1. n= new disk
297   #2. p= primary disk   # 2. p= primary disk
298   #3. 1= first partition   # 3. 1= first partition
299   #4. ''= default sector start   # 4. ''= default sector start
300   #5. ''= defaul sector end   # 5. ''= defaul sector end
301   #6. a= bootable flag   # 6. a= bootable flag
302   #7. 1= boot flag for partition 1   # 7. 1= boot flag for partition 1
303   #8. w= write/quit   # 8. n= new disk
304   fdisk ${HDD} &> /dev/null << EOF   #10. p= primary disk
305     #11. 2= second partition
306     #12. ''= default sector start
307     #13. ''= defaul sector end
308     #14. w= write/quit
309     fdisk ${HDD} &> /dev/null << EOF
310  n  n
311  p  p
312  1  1
313    
314    +50M
315    a
316    1
317    n
318    p
319    2
320    
321    
322    w
323    EOF
324     fi
325     else
326     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
327     then
328     ## setup one bootable partition
329     #1. n= new disk
330     #2. p= primary disk
331     #3. 1= first partition
332     #4. 2= default sector start // small disk needs more space for grub2 mbr sector
333     #5. ''= defaul sector end
334     #6. a= bootable flag
335     #7. 1= boot flag for partition 1
336     #8. w= write/quit
337     fdisk ${HDD} &> /dev/null << EOF
338    n
339    p
340    1
341    2
342    
343  a  a
344  1  1
345  w  w
346  EOF  EOF
347   fi   else
348  }   ## setup one bootable partition
349     #1. n= new disk
350     #2. p= primary disk
351     #3. 1= first partition
352     #4. ''= default sector start
353     #5. ''= defaul sector end
354     #6. a= bootable flag
355     #7. 1= boot flag for partition 1
356     #8. w= write/quit
357     fdisk ${HDD} &> /dev/null << EOF
358    n
359    p
360    1
361    
 setup_hdd_partitions_manual()  
 {  
  ROOTHDD="${HDD}1"  
  SWAPHDD=""  
  BOOTHDD=""  
  cfdisk ${HDD} || dialog_die  
 }  
362    
363  setup_hdd_format()  a
364  {  1
365   # sanity check - should not happen  w
366   if is_mounted --device "${ROOTHDD}"  EOF
367   then   fi
368   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2   fi
369   umount "${ROOTHDD}"   else
370     cfdisk ${HDD} || dialog_die
371   fi   fi
   
  mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die  
372  }  }
373    
374  install_mount_rootfs()  setup_hdd_format()
 {  
  is_mounted --location "${INSTALLROOT}" || mount "${ROOTHDD}" "${INSTALLROOT}"  
  install -d ${INSTALLROOT}/boot || dialog_die  
 }  
   
 install_system_image()  
 {  
  pushd ${INSTALLROOT} > /dev/null  
  tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT}  
  popd > /dev/null  
 }  
   
 install_bootsector_chroot()  
375  {  {
376   local my_roothdd   install -d /tmp
377   local grubconf=${INSTALLROOT}/boot/grub/grub.conf   :> /tmp/format.log
  local grub2conf=/boot/grub/grub.cfg  
378    
379   # check for grub2   if [[ -n ${SWAPHDD} ]]
  if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]]  
380   then   then
381   # needed by grub-mkconfig on the first run   # sanity check - should not happen
382   if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]   if is_mounted --device "${SWAPHDD}"
383   then   then
384   install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die   echo "format: device ${SWAPHDD} is already mounted, umount it" >&2
385     umount "${SWAPHDD}"
386   fi   fi
387     mkswap ${SWAPHDD} || die
388     fi
389    
390   # set kernelopts   if [[ -n ${BOOTHDD} ]]
391   if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]   then
392   then   # sanity check - should not happen
393   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die   if is_mounted --device "${BOOTHDD}"
  else  
  echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
  fi  
  echo 'grub-mkdevicemap' > ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "exit 0" >> ${INSTALLROOT}/root/.installrc || dialog_die  
   
  # grub-legacy  
  else  
  ### grubconf schreiben  
  source ${INSTALLROOT}/boot/kernelversion  
   
  #for alx only  
  if [ -e ${INSTALLROOT}/etc/alx_version ]  
  then  
  OLD_ALXVER="${ALXVER}"  
  source ${INSTALLROOT}/etc/alx_version  
  KRNVER="ALX-${ALXVER}"  
  ALXVER="${OLD_ALXVER}"  
  fi  
   
  [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"  
  [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"  
  [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"  
   
  # uuid support  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
   
  : > ${grubconf} || dialog_die  
  echo "default 0" >> ${grubconf} || dialog_die  
  echo "timeout 3" >> ${grubconf} || dialog_die  
  # using current root password  
  echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || dialog_die  
   
  echo  >> ${grubconf} || dialog_die  
  echo "# normal boot" >> ${grubconf} || dialog_die  
  echo "title ${KRNVER}" >> ${grubconf} || dialog_die  
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
394   then   then
395   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   echo "format: device ${BOOTHDD} is already mounted, umount it" >&2
396     umount "${BOOTHDD}"
397   fi   fi
398    
399   echo >> ${grubconf} || dialog_die   mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die
400   echo "# admin boot" >> ${grubconf} || dialog_die   fi
  echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die  
  echo "lock"  >> ${grubconf} || dialog_die  
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die  
  fi  
401    
402   echo >> ${grubconf} || dialog_die   if [[ -n ${ROOTHDD} ]]
403   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die   then
404   echo "lock"  >> ${grubconf} || dialog_die   # sanity check - should not happen
405   echo "root (hd0,0)" >> ${grubconf} || dialog_die   if is_mounted --device "${ROOTHDD}"
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
406   then   then
407   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2
408     umount "${ROOTHDD}"
409   fi   fi
410    
411   # bootsector schreiben chrooted schreiben (lfs/magellan)   mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die
  cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF  
 /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null  
 root (hd0,0)  
 setup (hd0)  
 quit  
 EOF  
 exit 0  
 CHROOTEOF  
  fi  
   
  # run installrc  
  chrooted /bin/bash --rcfile /root/.installrc -i  
  rm ${INSTALLROOT}/root/.installrc  
 }  
   
 install_initrd_chroot()  
 {  
  # only generate initrds if the cmd exists  
  is_initrd_supported || return 0  
   
  DISKMODS="sd_mod"  
  OLDPATAMODS="amd74xx piix sis5513 via82cxxx"  
  PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"  
  SATAMODS="sata_via sata_sis sata_nv"  
  DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"  
  OTHERMODS=""  
  case ${SPECIALDEVICE} in  
  zotac_intel) FBMODS=""; DRMMODS="i915" ;;  
  zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;  
  rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards  
  # not working with kms enabled drivers -> segfaults  
  #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer  
  maxdata) FBMODS="" ;;  
  *) FBMODS="uvesafb" ;;  
  esac  
   
  if [[ ${FORMFACTOR} = laptop ]]  
  then  
  OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"  
412   fi   fi
413    }
414    
415   # install an appropriate uvesafb.conf  install_system_image()
416   install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die  {
417   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die   pushd ${INSTALLROOT} > /dev/null
418     tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT}
419   # install an appropriate viafb.conf   popd > /dev/null
  echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die  
   
  # install an appropriate i810fb.conf  
  echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"  > ${INSTALLROOT}/etc/modprobe.d/i810fb.conf || dialog_die  
   
  cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF  
 echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd  
 mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null  
 exit 0  
 CHROOTEOF  
   
  # run installrc  
  chrooted /bin/bash --rcfile /root/.installrc -i  
  rm ${INSTALLROOT}/root/.installrc  
420  }  }
421    
422  install_system_settings()  install_system_settings()
# Line 623  install_system_settings() Line 426  install_system_settings()
426   # write fstab   # write fstab
427   CONFIG="${INSTALLROOT}/etc/fstab"   CONFIG="${INSTALLROOT}/etc/fstab"
428   clearconfig   clearconfig
429   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1"   if [[ -n ${BOOTHDD} ]]
430     then
431     addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1"
432     fi
433     if [[ -n ${ROOTHDD} ]]
434     then
435     addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
436     fi
437     if [[ -n ${SWAPHDD} ]]
438     then
439     addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0"
440     fi
441   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
442   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
443    
# Line 634  install_system_settings() Line 448  install_system_settings()
448   addconfig 'NETWORKING="dhcp"'   addconfig 'NETWORKING="dhcp"'
449    
450   # intel framebuffer quirk   # intel framebuffer quirk
451   if [ -e ${INSTALLROOT}/etc/splash/splash.conf ]   CONFIG="${INSTALLROOT}/etc/splash/splash.conf"
452     if [ -e ${CONFIG} ] && [ -e /proc/fb ]
453   then   then
454   if [ -e /proc/fb ]   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
455   then   then
456   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
457   then   [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die
  fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')  
  if [[ ${fbdev} != 0 ]]  
  then  
  sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die  
  fi  
  fi  
458   fi   fi
459   fi   fi
460  }  }
461    
462  install_umount_rootfs()  
463    ### installer dialogs ###
464    
465    dialog_die()
466  {  {
467   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot   ERROR="$1"
468   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}   RETVAL="$?"
469     dialog_install_failure
470     exit 1
471  }  }
472    
473  install_do_reboot()  dialog_warning()
474  {  {
475   reboot   local retval
476    
477     yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"
478     retval=$?
479     if [[ ${retval} -eq 1 ]]
480     then
481     clear
482     echo $"The process was aborted."
483     exit 1
484     fi
485  }  }
486    
 #################################################  
 #     Install Ablauf Scripte #  
 #################################################  
487    
488  run_install_normal()  ### installer tasks ###
489    
490    task_setup_system_menu()
491  {  {
492   dialog_hardware_detection   local mode
493     local retval
494    
495   dialog_setup_hdd_partitions_manual   mode="$(dialog_setup_system_menu)"
496   dialog_setup_hdd_format   retval=$?
497   setup_hdd_format > /dev/null   [[ ${retval} -eq 1 ]] && return 1
498   install_mount_rootfs   if [[ ${retval} -eq 0 ]]
499   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image   then
500     case "${mode}" in
501     "1") run_install auto ;;
502     "2") run_install normal ;;
503     "") task_setup_system_menu;;
504     esac
505     fi
506    }
507    
508   dialog_install_settings  task_hardware_detection()
509   sleep 1  {
510   install_system_settings   local message
511   if is_initrd_supported  
512     run_hardware_detection_disks
513    
514     message+=$"Harddrives:\n"
515    
516     if [[ ! -z ${ALL_DISKS} ]]
517   then   then
518   dialog_install_initrd   for i in ${ALL_DISKS}
519   initrd_config   do
520   initrd_install   message+="\Z3${i}\Zn "
521     done
522     message+="\n"
523   fi   fi
524    
525   dialog_install_bootsector   if [[ ! -z ${ALL_CDROMS} ]]
526   bootloader_config   then
527   bootloader_install   message+="\n"
528     message+=$"Optical disk drives:\n"
529     for i in ${ALL_CDROMS}
530     do
531     message+="\Z3${i}\Zn"
532     done
533     message+="\n"
534     fi
535    
536   install_umount_rootfs   # other devices
537   dialog_install_successful   run_hardware_detection
538     case "${SPECIALDEVICE}" in
539     zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
540     rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
541     maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
542     *) message+=$"\n\ZnCommon device detected.\Zn" ;;
543     esac
544     if [[ ${FORMFACTOR} = laptop ]]
545     then
546     message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
547     fi
548     if [[ ${FLASHDISK} = 1 ]]
549     then
550     message+=$"\n\ZnFlash memory detected.\Zn"
551     message+=$"\n\ZnF2FS will be used as default filesystem withn the auto installation mode.\Zn"
552     fi
553    
554     messagebox -y 12 -h $"Detected hardware:" "${message}"
555    }
556    
557    task_setup_hdd_partitions()
558    {
559     local i
560     local retval
561    
562     if [[ -z ${ALL_DISKS} ]]
563     then
564     dialog_no_harddrive_found
565     exit 1
566     else
567     HDD=$(dialog_select_target_harddrive)
568     retval=$?
569     [[ ${retval} -eq 1 ]] && return 1
570     if [[ ${retval} -eq 0 ]]
571     then
572     dialog_setup_hdd_info
573     setup_hdd_partitions
574     fi
575     fi
576    }
577    
578    task_main()
579    {
580     local method=0
581     local retval
582    
583     while [[ ${method} -le 2 ]]
584     do
585     method=$(dialog_main)
586     retval=$?
587     [[ ${retval} -eq 1 ]] && exit 1
588     if [[ ${retval} -eq 0 ]]
589     then
590     case ${method} in
591     "1") task_setup_system_menu ;;
592     "2") task_hardware_detection ;;
593     "3") install_do_reboot ;;
594     "4") /bin/bash --login -i ;;
595     esac
596     fi
597     done
598  }  }
599    
600  run_install_auto()  run_install()
601  {  {
602   dialog_hardware_detection   local method="$1"
603    
604     task_hardware_detection
605    
606     case "${method}" in
607     auto)
608     if [[ ${FLASHDISK} = 1 ]]
609     then
610     export BOOTHDD="${HDD}1"
611     export SWAPHDD=""
612     export ROOTHDD="${HDD}2"
613     export FORMAT_FILESYSTEM_BOOTHDD="f2fs"
614     export FORMAT_FILESYSTEM_ROOTHDD="ext2"
615     else
616     export BOOTHDD=""
617     export SWAPHDD=""
618     export ROOTHDD="${HDD}1"
619     export FORMAT_FILESYSTEM_BOOTHDD=""
620     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
621     fi
622     export INSTALL_METHOD="${method}"
623     ;;
624     normal)
625     export BOOTHDD="${HDD}1"
626     export SWAPHDD="${HDD}2"
627     export ROOTHDD="${HDD}3"
628     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
629     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
630     export INSTALL_METHOD="${method}"
631     ;;
632     single)
633     export BOOTHDD=""
634     export SWAPHDD=""
635     export ROOTHDD="${HDD}1"
636     export FORMAT_FILESYSTEM_BOOTHDD=""
637     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
638     export INSTALL_METHOD="${method}"
639     ;;
640     flash)
641     export BOOTHDD="${HDD}1"
642     export SWAPHDD=""
643     export ROOTHDD="${HDD}2"
644     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
645     export FORMAT_FILESYSTEM_ROOTHDD="f2fs"
646     export INSTALL_METHOD="${method}"
647     ;;
648     *)
649     die "Unknown install method '${method}', aborting."
650     ;;
651     esac
652    
653   dialog_setup_hdd_partitions_auto   task_setup_hdd_partitions
654   dialog_setup_hdd_format   dialog_setup_hdd_format
655   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
656   install_mount_rootfs   mount_rootfs
657   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image
658    
659   dialog_install_settings   dialog_install_settings
# Line 717  run_install_auto() Line 670  run_install_auto()
670   bootloader_config   bootloader_config
671   bootloader_install   bootloader_install
672    
673   install_umount_rootfs   umount_rootfs
674   dialog_install_successful   dialog_install_successful
675  }  }
676    
677  # set some proper traps  # set some proper traps
678  trap "trap_exit" SIGINT SIGQUIT  trap "trap_exit" SIGINT SIGQUIT
679    
680  dialog_main  task_main
681    
682  exit 0  exit 0

Legend:
Removed from v.2443  
changed lines
  Added in v.2890