Magellan Linux

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

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

revision 2500 by niro, Wed Jan 8 13:20:29 2014 UTC revision 2889 by niro, Fri Jul 31 10:55:16 2015 UTC
# Line 40  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 71  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    # -> 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 ###  ### helper scripts ###
76    
# Line 81  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
# Line 103  mount_rootfs() Line 104  mount_rootfs()
104  {  {
105   local retval   local retval
106    
107   if is_mounted --location "${INSTALLROOT}"   if [[ -n ${SWAPHDD} ]]
108   then   then
109   echo $"${INSTALLROOT} already mounted" >&2   swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'"
110   else   fi
111   mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"  
112     if [[ -n ${ROOTHDD} ]]
113     then
114     if is_mounted --location "${INSTALLROOT}"
115     then
116     echo $"${INSTALLROOT} already mounted" >&2
117     else
118     mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"
119     fi
120   fi   fi
121    
122   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot
123    
124     if [[ -n ${BOOTHDD} ]]
125     then
126     if is_mounted --location "${INSTALLROOT}"/boot
127     then
128     echo $"${INSTALLROOT}/boot already mounted" >&2
129     else
130     mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'"
131     fi
132     fi
133  }  }
134    
135  umount_rootfs()  umount_rootfs()
136  {  {
137   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot
138   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}
139    
140     if [[ -n ${SWAPHDD} ]]
141     then
142     swapoff ${SWAPHDD} || die
143     fi
144  }  }
145    
146  install_do_reboot()  install_do_reboot()
# Line 129  run_hardware_detection() Line 154  run_hardware_detection()
154    
155   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
156    
157   ## check for special devices/clients:   # check for special devices/clients:
158   ## 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
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'   # 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"
173   ## there are to zotac types in the wild, nvidia based gfx and intel   # there are to zotac types in the wild, nvidia based gfx and intel
174   #if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
175   #then   then
176   #export SPECIALDEVICE="zotac_nvidia"   export SPECIALDEVICE="zotac_nvidia"
177   #else   else
178   #export SPECIALDEVICE="zotac_intel"   export SPECIALDEVICE="zotac_intel"
179   #fi   fi
180   #fi   fi
181    
182   # check for special devices/clients:   # check for special devices/clients:
183   # 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 188  run_hardware_detection_disks() Line 213  run_hardware_detection_disks()
213   # all disks but exclude ramdisks   # all disks but exclude ramdisks
214   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')   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   # remove the boot device from ALL_DISKS if it was an usbstick
216   if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]   if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
217   then   then
218   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')
219   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
220   fi   fi
221   export ALL_CDROMS="$(get_hwinfo cdrom)"   export ALL_CDROMS="$(get_hwinfo cdrom)"
222  }  }
223    
224  setup_hdd_partitions_auto()  setup_hdd_partitions()
225  {  {
  ROOTHDD="${HDD}1"  
   
226   # sanity check - should not happen   # sanity check - should not happen
227   if is_mounted --device "${ROOTHDD}"   if is_mounted --device "${ROOTHDD}"
228   then   then
229   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2
230   umount "${ROOTHDD}"   umount "${ROOTHDD}"
231   fi   fi
232     if [[ -n ${BOOTHDD} ]]
  # run this only if FDISKPARTITIONBELOW256MB is not already 1  
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
233   then   then
234   if device_minimum_size "${HDD}" 256   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 242  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 262  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"  
  SWAPHDD=""  
  BOOTHDD=""  
  cfdisk ${HDD} || dialog_die  
 }  
   
304  setup_hdd_format()  setup_hdd_format()
305  {  {
306   # sanity check - should not happen   install -d /tmp
307   if is_mounted --device "${ROOTHDD}"   :> /tmp/format.log
308    
309     if [[ -n ${SWAPHDD} ]]
310   then   then
311   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2   # sanity check - should not happen
312   umount "${ROOTHDD}"   if is_mounted --device "${SWAPHDD}"
313     then
314     echo "format: device ${SWAPHDD} is already mounted, umount it" >&2
315     umount "${SWAPHDD}"
316     fi
317     mkswap ${SWAPHDD} || die
318   fi   fi
319    
320   mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die   if [[ -n ${BOOTHDD} ]]
321     then
322     # sanity check - should not happen
323     if is_mounted --device "${BOOTHDD}"
324     then
325     echo "format: device ${BOOTHDD} is already mounted, umount it" >&2
326     umount "${BOOTHDD}"
327     fi
328    
329     mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die
330     fi
331    
332     if [[ -n ${ROOTHDD} ]]
333     then
334     # sanity check - should not happen
335     if is_mounted --device "${ROOTHDD}"
336     then
337     echo "format: device ${ROOTHDD} is already mounted, umount it" >&2
338     umount "${ROOTHDD}"
339     fi
340    
341     mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die
342     fi
343  }  }
344    
345  install_system_image()  install_system_image()
346  {  {
347   pushd ${INSTALLROOT} > /dev/null   pushd ${INSTALLROOT} > /dev/null
348   tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT}   tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT}
349   popd > /dev/null   popd > /dev/null
350  }  }
351    
# Line 299  install_system_settings() Line 356  install_system_settings()
356   # write fstab   # write fstab
357   CONFIG="${INSTALLROOT}/etc/fstab"   CONFIG="${INSTALLROOT}/etc/fstab"
358   clearconfig   clearconfig
359   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1"   if [[ -n ${BOOTHDD} ]]
360     then
361     addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1"
362     fi
363     if [[ -n ${ROOTHDD} ]]
364     then
365     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"   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
372   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
373    
# Line 360  task_setup_system_menu() Line 428  task_setup_system_menu()
428   if [[ ${retval} -eq 0 ]]   if [[ ${retval} -eq 0 ]]
429   then   then
430   case "${mode}" in   case "${mode}" in
431   "1") run_install_auto ;;   "1") run_install auto ;;
432   "2") run_install_normal ;;   "2") run_install normal ;;
433   "") task_setup_system_menu;;   "") task_setup_system_menu;;
434   esac   esac
435   fi   fi
# Line 411  task_hardware_detection() Line 479  task_hardware_detection()
479   messagebox -y 12 -h $"Detected hardware:" "${message}"   messagebox -y 12 -h $"Detected hardware:" "${message}"
480  }  }
481    
482  task_setup_hdd_partitions_manual()  task_setup_hdd_partitions()
483  {  {
484   local i   local i
485   local retval   local retval
# Line 427  task_setup_hdd_partitions_manual() Line 495  task_setup_hdd_partitions_manual()
495   if [[ ${retval} -eq 0 ]]   if [[ ${retval} -eq 0 ]]
496   then   then
497   dialog_setup_hdd_info   dialog_setup_hdd_info
498   setup_hdd_partitions_manual   setup_hdd_partitions
  fi  
  fi  
 }  
   
 task_setup_hdd_partitions_auto()  
 {  
  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 ]]  
  then  
  dialog_setup_hdd_info_auto  
  dialog_setup_hdd_create_partitions  
  setup_hdd_partitions_auto  
499   fi   fi
500   fi   fi
501  }  }
# Line 476  task_main() Line 522  task_main()
522   done   done
523  }  }
524    
525  run_install_normal()  run_install()
526  {  {
527   task_hardware_detection   local method="$1"
   
  task_setup_hdd_partitions_manual  
  dialog_setup_hdd_format  
  setup_hdd_format > /dev/null  
  mount_rootfs  
  (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image  
   
  dialog_install_settings  
  sleep 1  
  install_system_settings  
  if is_initrd_supported  
  then  
  dialog_install_initrd  
  initrd_config  
  initrd_install  
  fi  
   
  dialog_install_bootsector  
  bootloader_config  
  bootloader_install  
   
  umount_rootfs  
  dialog_install_successful  
 }  
528    
 run_install_auto()  
 {  
529   task_hardware_detection   task_hardware_detection
530    
531   task_setup_hdd_partitions_auto   case "${method}" in
532     auto)
533     export BOOTHDD=""
534     export SWAPHDD=""
535     export ROOTHDD="${HDD}1"
536     export FORMAT_FILESYSTEM_BOOTHDD=""
537     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
538     export INSTALL_METHOD="${method}"
539     ;;
540     normal)
541     export BOOTHDD="${HDD}1"
542     export SWAPHDD="${HDD}2"
543     export ROOTHDD="${HDD}3"
544     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
545     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
546     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     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   mount_rootfs   mount_rootfs

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