Magellan Linux

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

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

revision 2427 by niro, Tue Jan 7 14:09:01 2014 UTC revision 2889 by niro, Fri Jul 31 10:55:16 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 27  for inc in %SYSCONFDIR%/installer.conf \ Line 28  for inc in %SYSCONFDIR%/installer.conf \
28   ${INSTALLER_LIBDIR}/functions/common.sh \   ${INSTALLER_LIBDIR}/functions/common.sh \
29   ${INSTALLER_LIBDIR}/functions/common-dialogs.sh \   ${INSTALLER_LIBDIR}/functions/common-dialogs.sh \
30   ${INSTALLER_LIBDIR}/functions/hwdetection.sh \   ${INSTALLER_LIBDIR}/functions/hwdetection.sh \
31     ${INSTALLER_LIBDIR}/functions/bootloader.sh \
32     ${INSTALLER_LIBDIR}/functions/initrd-tools.sh \
33   ${INSTALLER_LIBDIR}/functions/installer-dialogs.sh   ${INSTALLER_LIBDIR}/functions/installer-dialogs.sh
34  do  do
35   if [ -e ${inc} ]   if [ -e ${inc} ]
# Line 37  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  # some sane defaults  # some sane defaults
48  CDROOT="${DEFAULT_CDROOT}"  LIVEROOT="${DEFAULT_LIVEROOT}"
49    IMAGEROOT="${DEFAULT_IMAGEROOT}"
50  INSTALLROOT="${DEFAULT_INSTALLROOT}"  INSTALLROOT="${DEFAULT_INSTALLROOT}"
51  KERNELPKG="${DEFAULT_KERNELPKG}"  KERNELPKG="${DEFAULT_KERNELPKG}"
52  KERNELOPTS="${DEFAULT_KERNELOPTS}"  KERNELOPTS="${DEFAULT_KERNELOPTS}"
# Line 68  SPECIALDEVICE="" Line 57  SPECIALDEVICE=""
57  FORMFACTOR="${DEFAULT_FORMFACTOR}"  FORMFACTOR="${DEFAULT_FORMFACTOR}"
58  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"
59    
60  #################################################  # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
61  #  DIALOG BOXEN #  # -> now in images.conf
62  #################################################  CDIMAGENAME=""
63    TOTALLINES=""
64    CURRENTLINE=0
65    if [ -e ${IMAGEROOT}/images.conf ]
66    then
67     source ${IMAGEROOT}/images.conf
68     # check if all required variables are set
69     [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf"
70     [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf"
71    else
72     die "${IMAGEROOT}/images.conf not found"
73    fi
74    
75    ### helper scripts ###
76    
77  trap_exit()  trap_exit()
78  {  {
# Line 79  trap_exit() Line 81  trap_exit()
81   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys
82   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot
83   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}
84     [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD}
85    
86   echo $"Installation aborted."   echo $"Installation aborted."
87   exit 1   exit 1
88  }  }
89    
90  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()  
91  {  {
92   local SHDD="${HDD//\/dev\/}"   while [[ ${CURRENTLINE} != ${TOTALLINES} ]]
93     do
94   messagebox -h $"[ Harddrive partitioning ]" \   CURRENTLINE=$(grep -c . /tmp/install.log)
95   $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"   PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))
96     echo ${PERCENT}
97     sleep 1
98     done
99     rm -f /tmp/install.log
100     return 0
101  }  }
102    
103  dialog_setup_system_menu()  mount_rootfs()
104  {  {
  local mode  
105   local retval   local retval
106    
107   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 ]]  
  then  
  case "${mode}" in  
  "1") run_install_auto ;;  
  "2") run_install_normal ;;  
  "") dialog_setup_system_menu;;  
  esac  
  fi  
 }  
   
 dialog_hardware_detection()  
 {  
  local message  
   
  run_hardware_detection_disks  
   
  message+=$"Harddrives:\n"  
   
  if [[ ! -z ${ALL_DISKS} ]]  
  then  
  for i in ${ALL_DISKS}  
  do  
  message+="\Z3${i}\Zn "  
  done  
  message+="\n"  
  fi  
   
  if [[ ! -z ${ALL_CDROMS} ]]  
  then  
  message+="\n"  
  message+=$"Optical disk drives:\n"  
  for i in ${ALL_CDROMS}  
  do  
  message+="\Z3${i}\Zn"  
  done  
  message+="\n"  
  fi  
   
  # other devices  
  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 ]]  
108   then   then
109   message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving  mode.\Zn"   swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'"
110   fi   fi
111    
112   messagebox -y 15 -h $"Detected hardware:" "${message}"   if [[ -n ${ROOTHDD} ]]
 }  
   
 dialog_setup_hdd_partitions_manual()  
 {  
  local i  
  local retval  
   
  if [[ -z ${ALL_DISKS} ]]  
113   then   then
114   dialog_no_harddrive_found   if is_mounted --location "${INSTALLROOT}"
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
115   then   then
116   dialog_setup_hdd_info   echo $"${INSTALLROOT} already mounted" >&2
117   setup_hdd_partitions_manual   else
118     mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"
119   fi   fi
120   fi   fi
 }  
121    
122  dialog_setup_hdd_partitions_auto()   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot
 {  
  local i  
  local retval  
123    
124   if [[ -z ${ALL_DISKS} ]]   if [[ -n ${BOOTHDD} ]]
125   then   then
126   dialog_no_harddrive_found   if is_mounted --location "${INSTALLROOT}"/boot
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
127   then   then
128   dialog_setup_hdd_info_auto   echo $"${INSTALLROOT}/boot already mounted" >&2
129   dialog_setup_hdd_create_partitions   else
130   setup_hdd_partitions_auto   mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'"
131   fi   fi
132   fi   fi
133  }  }
134    
135  run_hardware_detection_disks()  umount_rootfs()
136  {  {
137   local bootdev   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot
138     is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}
139    
140   # all disks but exclude ramdisks   if [[ -n ${SWAPHDD} ]]
  export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')  
  # remove the boot device from ALL_DISKS if it was an usbstick  
  if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]  
141   then   then
142   bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')"   swapoff ${SWAPHDD} || die
  export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")  
143   fi   fi
  export ALL_CDROMS="$(get_hwinfo cdrom)"  
144  }  }
145    
146  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()  
147  {  {
148   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  
149  }  }
150    
 #################################################  
 # Install Komandos #  
 #################################################  
151  run_hardware_detection()  run_hardware_detection()
152  {  {
153   local hwinfo   local hwinfo
# Line 299  run_hardware_detection() Line 159  run_hardware_detection()
159   local removable=0   local removable=0
160   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
161   then   then
162   for i in /sys/block/[hs]d*/removable   #for i in /sys/block/[hs]d*/removable
163   do   #do
164   if [[ $(< ${i}) = 1 ]]   # if [[ $(< ${i}) = 1 ]]
165   then   # then
166   removable=1   # removable=1
167   fi   # fi
168   done   #done
169     # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card'
170    
171   # only add this for grub legacy, grub2 detect these settings on its own   # only add this for grub legacy, grub2 detect these settings on its own
172   export GRUBLEGACYOPTS="rootdelay=8"   export GRUBLEGACYOPTS="rootdelay=8"
# Line 345  run_hardware_detection() Line 206  run_hardware_detection()
206   fi   fi
207  }  }
208    
209  hdd_size_below_256mb()  run_hardware_detection_disks()
210  {  {
211   local hdd="$1"   local bootdev
  local size  
  local retval  
  [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"  
212    
213   size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')   # all disks but exclude ramdisks
214   if [[ ${size} -le 257000000 ]]   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')
215     # remove the boot device from ALL_DISKS if it was an usbstick
216     if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
217   then   then
218   retval="0"   bootdev=$(grep "[[:space:]]${LIVEROOT}[[:space:]]" /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')
219   else   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
  retval="1"  
220   fi   fi
221     export ALL_CDROMS="$(get_hwinfo cdrom)"
  return "${retval}"  
222  }  }
223    
224  setup_hdd_partitions_auto()  setup_hdd_partitions()
225  {  {
226   ROOTHDD="${HDD}1"   # sanity check - should not happen
227     if is_mounted --device "${ROOTHDD}"
228   # run this only if FDISKPARTITIONBELOW256MB is not already 1   then
229   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2
230     umount "${ROOTHDD}"
231     fi
232     if [[ -n ${BOOTHDD} ]]
233   then   then
234   if hdd_size_below_256mb ${HDD}   if is_mounted --device "${BOOTHDD}"
235   then   then
236   FDISKPARTIONBELOW256MB=1   echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2
237   else   umount "${BOOTHDD}"
  FDISKPARTIONBELOW256MB=0  
238   fi   fi
239   fi   fi
240    
241   ## delete disk   if [[ ${INSTALL_METHOD} = auto ]]
  dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die  
   
  if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]  
242   then   then
243   ## setup one bootable partition   # run this only if FDISKPARTITIONBELOW256MB is not already 1
244   #1. n= new disk   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
245   #2. p= primary disk   then
246   #3. 1= first partition   if device_minimum_size "${HDD}" 256
247   #4. 2= default sector start // small disk needs more space for grub2 mbr sector   then
248   #5. ''= defaul sector end   FDISKPARTIONBELOW256MB=1
249   #6. a= bootable flag   else
250   #7. 1= boot flag for partition 1   FDISKPARTIONBELOW256MB=0
251   #8. w= write/quit   fi
252   fdisk ${HDD} &> /dev/null << EOF   fi
253    
254     ## delete disk
255     dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die
256    
257     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
258     then
259     ## setup one bootable partition
260     #1. n= new disk
261     #2. p= primary disk
262     #3. 1= first partition
263     #4. 2= default sector start // small disk needs more space for grub2 mbr sector
264     #5. ''= defaul sector end
265     #6. a= bootable flag
266     #7. 1= boot flag for partition 1
267     #8. w= write/quit
268     fdisk ${HDD} &> /dev/null << EOF
269  n  n
270  p  p
271  1  1
# Line 402  a Line 275  a
275  1  1
276  w  w
277  EOF  EOF
278   else   else
279   ## setup one bootable partition   ## setup one bootable partition
280   #1. n= new disk   #1. n= new disk
281   #2. p= primary disk   #2. p= primary disk
282   #3. 1= first partition   #3. 1= first partition
283   #4. ''= default sector start   #4. ''= default sector start
284   #5. ''= defaul sector end   #5. ''= defaul sector end
285   #6. a= bootable flag   #6. a= bootable flag
286   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
287   #8. w= write/quit   #8. w= write/quit
288   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
289  n  n
290  p  p
291  1  1
# Line 422  a Line 295  a
295  1  1
296  w  w
297  EOF  EOF
298     fi
299     else
300     cfdisk ${HDD} || dialog_die
301   fi   fi
302  }  }
303    
 setup_hdd_partitions_manual()  
 {  
  ROOTHDD="${HDD}1"  
   
  ## hdds partitionieren manual  
  cfdisk ${HDD} || dialog_die  
 }  
   
304  setup_hdd_format()  setup_hdd_format()
305  {  {
306   mke2fs -j -q ${ROOTHDD} || dialog_die   install -d /tmp
307  }   :> /tmp/format.log
   
 install_mount_rootfs()  
 {  
  mount ${ROOTHDD} ${INSTALLROOT} || dialog_die  
  install -d ${INSTALLROOT}/boot || dialog_die  
  cd ${INSTALLROOT} || dialog_die  
 }  
308    
309  install_system_image()   if [[ -n ${SWAPHDD} ]]
 {  
  tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT}  
 }  
   
 install_bootsector_chroot()  
 {  
  local my_roothdd  
  local grubconf=${INSTALLROOT}/boot/grub/grub.conf  
  local grub2conf=/boot/grub/grub.cfg  
   
  # check for grub2  
  if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]]  
310   then   then
311   # needed by grub-mkconfig on the first run   # sanity check - should not happen
312   if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]   if is_mounted --device "${SWAPHDD}"
313   then   then
314   install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die   echo "format: device ${SWAPHDD} is already mounted, umount it" >&2
315     umount "${SWAPHDD}"
316   fi   fi
317     mkswap ${SWAPHDD} || die
318     fi
319    
320   # set kernelopts   if [[ -n ${BOOTHDD} ]]
321   if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]   then
322     # sanity check - should not happen
323     if is_mounted --device "${BOOTHDD}"
324   then   then
325   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die   echo "format: device ${BOOTHDD} is already mounted, umount it" >&2
326   else   umount "${BOOTHDD}"
  echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
327   fi   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  
328    
329   # grub-legacy   mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die
330   else   fi
  ### grubconf schreiben  
  source ${INSTALLROOT}/boot/kernelversion  
331    
332   #for alx only   if [[ -n ${ROOTHDD} ]]
333   if [ -e ${INSTALLROOT}/etc/alx_version ]   then
334     # sanity check - should not happen
335     if is_mounted --device "${ROOTHDD}"
336   then   then
337   OLD_ALXVER="${ALXVER}"   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2
338   source ${INSTALLROOT}/etc/alx_version   umount "${ROOTHDD}"
  KRNVER="ALX-${ALXVER}"  
  ALXVER="${OLD_ALXVER}"  
339   fi   fi
340    
341   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die
342   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   fi
343   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"  }
   
  # uuid support  
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
  else  
  my_roothdd="${ROOTHDD}"  
  fi  
344    
345   : > ${grubconf} || dialog_die  install_system_image()
346   echo "default 0" >> ${grubconf} || dialog_die  {
347   echo "timeout 3" >> ${grubconf} || dialog_die   pushd ${INSTALLROOT} > /dev/null
348   # using current root password   tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT}
349   echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || dialog_die   popd > /dev/null
350    }
351    
352   echo  >> ${grubconf} || dialog_die  install_system_settings()
353   echo "# normal boot" >> ${grubconf} || dialog_die  {
354   echo "title ${KRNVER}" >> ${grubconf} || dialog_die   local CONFIG
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die  
  fi  
355    
356   echo >> ${grubconf} || dialog_die   # write fstab
357   echo "# admin boot" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/fstab"
358   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die   clearconfig
359   echo "lock"  >> ${grubconf} || dialog_die   if [[ -n ${BOOTHDD} ]]
360   echo "root (hd0,0)" >> ${grubconf} || dialog_die   then
361   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die   addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1"
362   if is_initrd_supported   fi
363   then   if [[ -n ${ROOTHDD} ]]
364   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   then
365   fi   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
366     fi
367     if [[ -n ${SWAPHDD} ]]
368     then
369     addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0"
370     fi
371     addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
372     addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
373    
374   echo >> ${grubconf} || dialog_die   # install network config skeleton
375   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0"
376   echo "lock"  >> ${grubconf} || dialog_die   clearconfig
377   echo "root (hd0,0)" >> ${grubconf} || dialog_die   addconfig 'ONBOOT="yes"'
378   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die   addconfig 'NETWORKING="dhcp"'
379   if is_initrd_supported  
380     # intel framebuffer quirk
381     CONFIG="${INSTALLROOT}/etc/splash/splash.conf"
382     if [ -e ${CONFIG} ] && [ -e /proc/fb ]
383     then
384     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
385   then   then
386   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
387     [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die
388   fi   fi
   
  # bootsector schreiben chrooted schreiben (lfs/magellan)  
  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  
389   fi   fi
390    }
391    
  ## enter chroot  
  mount -t proc proc ${INSTALLROOT}/proc  
  mount -t sysfs sysfs ${INSTALLROOT}/sys  
  mount -o bind /dev ${INSTALLROOT}/dev  
  chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLROOT}/proc  
  umount ${INSTALLROOT}/sys  
  umount ${INSTALLROOT}/dev  
  rm ${INSTALLROOT}/root/.installrc  
 }  
   
 is_initrd_supported()  
 {  
  # only generate initrds if the cmd exists  
  [[ -x ${INSTALLROOT}/sbin/mkinitrd ]] && return 0  
  return 1  
 }  
   
 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  
392    
393   if [[ ${FORMFACTOR} = laptop ]]  ### installer dialogs ###
  then  
  OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"  
  fi  
394    
395   # install an appropriate uvesafb.conf  dialog_die()
396   install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die  {
397   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die   ERROR="$1"
398     RETVAL="$?"
399     dialog_install_failure
400     exit 1
401    }
402    
403   # install an appropriate viafb.conf  dialog_warning()
404   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die  {
405     local retval
406    
407   # install an appropriate i810fb.conf   yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"
408   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   retval=$?
409     if [[ ${retval} -eq 1 ]]
410     then
411     clear
412     echo $"The process was aborted."
413     exit 1
414     fi
415    }
416    
  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  
417    
418   ## enters chroot  ### installer tasks ###
  mount -t proc proc ${INSTALLROOT}/proc  
  mount -t sysfs sysfs ${INSTALLROOT}/sys  
  mount -o bind /dev ${INSTALLROOT}/dev  
  chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLROOT}/proc  
  umount ${INSTALLROOT}/sys  
  umount ${INSTALLROOT}/dev  
  rm ${INSTALLROOT}/root/.installrc  
 }  
419    
420  is_uuid_supported()  task_setup_system_menu()
421  {  {
422   if [[ -x $(type -P busybox.mkinitrd) ]]   local mode
423     local retval
424    
425     mode="$(dialog_setup_system_menu)"
426     retval=$?
427     [[ ${retval} -eq 1 ]] && return 1
428     if [[ ${retval} -eq 0 ]]
429   then   then
430   # only detect uuids if supported   case "${mode}" in
431   if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]   "1") run_install auto ;;
432   then   "2") run_install normal ;;
433   return 0   "") task_setup_system_menu;;
434   fi   esac
435   fi   fi
   
  return 1  
436  }  }
437    
438  get_uuid()  task_hardware_detection()
439  {  {
440   local UUID   local message
  local SEC_TYPE  
  local TYPE  
441    
442   local dev="$1"   run_hardware_detection_disks
443   [[ -z ${dev} ]] && dialog_die "no dev given"  
444     message+=$"Harddrives:\n"
445    
446   # check if given device is already an UUID   if [[ ! -z ${ALL_DISKS} ]]
  if [[ ${dev/UUID=/}x != ${dev}x ]]  
447   then   then
448   eval "${dev}"   for i in ${ALL_DISKS}
449   else   do
450   eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')   message+="\Z3${i}\Zn "
451     done
452     message+="\n"
453   fi   fi
  echo "${UUID}"  
 }  
454    
455  install_system_settings()   if [[ ! -z ${ALL_CDROMS} ]]
 {  
  # schreibe fstab  
  if is_uuid_supported  
456   then   then
457   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   message+="\n"
458   else   message+=$"Optical disk drives:\n"
459   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   for i in ${ALL_CDROMS}
460     do
461     message+="\Z3${i}\Zn"
462     done
463     message+="\n"
464   fi   fi
  # not needed busybox loads all with swapon -a, even if not mentioned in fstab  
  #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
  echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
  echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
465    
466   # install network config skeleton   # other devices
467   install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die   run_hardware_detection
468     case "${SPECIALDEVICE}" in
469     zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
470     rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
471     maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
472     *) message+=$"\n\ZnCommon device detected.\Zn" ;;
473     esac
474     if [[ ${FORMFACTOR} = laptop ]]
475     then
476     message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
477     fi
478    
479   # intel framebufer quirk   messagebox -y 12 -h $"Detected hardware:" "${message}"
480   if [[ -e /proc/fb ]]  }
481    
482    task_setup_hdd_partitions()
483    {
484     local i
485     local retval
486    
487     if [[ -z ${ALL_DISKS} ]]
488   then   then
489   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]   dialog_no_harddrive_found
490     exit 1
491     else
492     HDD=$(dialog_select_target_harddrive)
493     retval=$?
494     [[ ${retval} -eq 1 ]] && return 1
495     if [[ ${retval} -eq 0 ]]
496   then   then
497   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   dialog_setup_hdd_info
498   if [[ ${fbdev} != 0 ]]   setup_hdd_partitions
  then  
  sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die  
  fi  
499   fi   fi
500   fi   fi
501  }  }
502    
503  install_umount_rootfs()  task_main()
504  {  {
505   cd /   local method=0
506   umount ${INSTALLROOT}/boot || dialog_die   local retval
  umount ${INSTALLROOT} || dialog_die  
 }  
507    
508  install_do_reboot()   while [[ ${method} -le 2 ]]
509  {   do
510   reboot   method=$(dialog_main)
511     retval=$?
512     [[ ${retval} -eq 1 ]] && exit 1
513     if [[ ${retval} -eq 0 ]]
514     then
515     case ${method} in
516     "1") task_setup_system_menu ;;
517     "2") task_hardware_detection ;;
518     "3") install_do_reboot ;;
519     "4") /bin/bash --login -i ;;
520     esac
521     fi
522     done
523  }  }
524    
525  #################################################  run_install()
 #     Install Ablauf Scripte #  
 #################################################  
   
 run_install_normal()  
526  {  {
527   dialog_hardware_detection   local method="$1"
528    
529   dialog_setup_hdd_partitions_manual   task_hardware_detection
  dialog_setup_hdd_format  
  setup_hdd_format > /dev/null  
  install_mount_rootfs  
  (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image  
530    
531   dialog_install_settings   case "${method}" in
532   sleep 1   auto)
533   install_system_settings   export BOOTHDD=""
534   dialog_install_initrd   export SWAPHDD=""
535   install_initrd_chroot   export ROOTHDD="${HDD}1"
536     export FORMAT_FILESYSTEM_BOOTHDD=""
537   dialog_install_bootsector   export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
538   install_bootsector_chroot   export INSTALL_METHOD="${method}"
539     ;;
540   install_umount_rootfs   normal)
541   dialog_install_successful   export BOOTHDD="${HDD}1"
542  }   export SWAPHDD="${HDD}2"
543     export ROOTHDD="${HDD}3"
544  run_install_auto()   export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
545  {   export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
546   dialog_hardware_detection   export INSTALL_METHOD="${method}"
547     ;;
548     single)
549     export BOOTHDD=""
550     export SWAPHDD=""
551     export ROOTHDD="${HDD}1"
552     export FORMAT_FILESYSTEM_BOOTHDD=""
553     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
554     export INSTALL_METHOD="${method}"
555     ;;
556     flash)
557     export BOOTHDD="${HDD}1"
558     export SWAPHDD=""
559     export ROOTHDD="${HDD}2"
560     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
561     export FORMAT_FILESYSTEM_ROOTHDD="f2fs"
562     export INSTALL_METHOD="${method}"
563     ;;
564     *)
565     die "Unknown install method '${method}', aborting."
566     ;;
567     esac
568    
569   dialog_setup_hdd_partitions_auto   task_setup_hdd_partitions
570   dialog_setup_hdd_format   dialog_setup_hdd_format
571   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
572   install_mount_rootfs   mount_rootfs
573   (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
574    
575   dialog_install_settings   dialog_install_settings
576   sleep 1   sleep 1
577   install_system_settings   install_system_settings
578   dialog_install_initrd   if is_initrd_supported
579   install_initrd_chroot   then
580     dialog_install_initrd
581     initrd_config
582     initrd_install
583     fi
584    
585   dialog_install_bootsector   dialog_install_bootsector
586   install_bootsector_chroot   bootloader_config
587     bootloader_install
588    
589   install_umount_rootfs   umount_rootfs
590   dialog_install_successful   dialog_install_successful
591  }  }
592    
593  # set some proper traps  # set some proper traps
594  trap "trap_exit" SIGINT SIGQUIT  trap "trap_exit" SIGINT SIGQUIT
595    
596  dialog_main  task_main
597    
598  exit 0  exit 0

Legend:
Removed from v.2427  
changed lines
  Added in v.2889