103 |
{ |
{ |
104 |
local retval |
local retval |
105 |
|
|
106 |
if is_mounted --location "${INSTALLROOT}" |
if [[ -n ${SWAPHDD} ]] |
107 |
then |
then |
108 |
echo $"${INSTALLROOT} already mounted" >&2 |
swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'" |
|
else |
|
|
mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
|
109 |
fi |
fi |
110 |
|
|
111 |
|
if [[ -n ${ROOTHDD} ]] |
112 |
|
then |
113 |
|
if is_mounted --location "${INSTALLROOT}" |
114 |
|
then |
115 |
|
echo $"${INSTALLROOT} already mounted" >&2 |
116 |
|
else |
117 |
|
mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
118 |
|
fi |
119 |
|
fi |
120 |
|
|
121 |
[[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
[[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
122 |
|
|
123 |
|
if [[ -n ${BOOTHDD} ]] |
124 |
|
then |
125 |
|
if is_mounted --location "${INSTALLROOT}"/boot |
126 |
|
then |
127 |
|
echo $"${INSTALLROOT}/boot already mounted" >&2 |
128 |
|
else |
129 |
|
mount "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" |
130 |
|
fi |
131 |
|
fi |
132 |
} |
} |
133 |
|
|
134 |
umount_rootfs() |
umount_rootfs() |
135 |
{ |
{ |
136 |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
137 |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
138 |
|
|
139 |
|
if [[ -n ${SWAPHDD} ]] |
140 |
|
then |
141 |
|
swapoff ${SWAPHDD} || die |
142 |
|
fi |
143 |
} |
} |
144 |
|
|
145 |
install_do_reboot() |
install_do_reboot() |
220 |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
221 |
} |
} |
222 |
|
|
223 |
setup_hdd_partitions_auto() |
setup_hdd_partitions() |
224 |
{ |
{ |
|
ROOTHDD="${HDD}1" |
|
|
|
|
225 |
# sanity check - should not happen |
# sanity check - should not happen |
226 |
if is_mounted --device "${ROOTHDD}" |
if is_mounted --device "${ROOTHDD}" |
227 |
then |
then |
228 |
echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 |
echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 |
229 |
umount "${ROOTHDD}" |
umount "${ROOTHDD}" |
230 |
fi |
fi |
231 |
|
if [[ -n ${BOOTHDD} ]] |
|
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
|
|
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
|
232 |
then |
then |
233 |
if device_minimum_size "${HDD}" 256 |
if is_mounted --device "${BOOTHDD}" |
234 |
then |
then |
235 |
FDISKPARTIONBELOW256MB=1 |
echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2 |
236 |
else |
umount "${BOOTHDD}" |
|
FDISKPARTIONBELOW256MB=0 |
|
237 |
fi |
fi |
238 |
fi |
fi |
239 |
|
|
240 |
## delete disk |
if [[ ${INSTALL_METHOD} = auto ]] |
|
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
|
|
|
|
|
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
|
241 |
then |
then |
242 |
## setup one bootable partition |
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
243 |
#1. n= new disk |
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
244 |
#2. p= primary disk |
then |
245 |
#3. 1= first partition |
if device_minimum_size "${HDD}" 256 |
246 |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
then |
247 |
#5. ''= defaul sector end |
FDISKPARTIONBELOW256MB=1 |
248 |
#6. a= bootable flag |
else |
249 |
#7. 1= boot flag for partition 1 |
FDISKPARTIONBELOW256MB=0 |
250 |
#8. w= write/quit |
fi |
251 |
fdisk ${HDD} &> /dev/null << EOF |
fi |
252 |
|
|
253 |
|
## delete disk |
254 |
|
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
255 |
|
|
256 |
|
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
257 |
|
then |
258 |
|
## setup one bootable partition |
259 |
|
#1. n= new disk |
260 |
|
#2. p= primary disk |
261 |
|
#3. 1= first partition |
262 |
|
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
263 |
|
#5. ''= defaul sector end |
264 |
|
#6. a= bootable flag |
265 |
|
#7. 1= boot flag for partition 1 |
266 |
|
#8. w= write/quit |
267 |
|
fdisk ${HDD} &> /dev/null << EOF |
268 |
n |
n |
269 |
p |
p |
270 |
1 |
1 |
274 |
1 |
1 |
275 |
w |
w |
276 |
EOF |
EOF |
277 |
else |
else |
278 |
## setup one bootable partition |
## setup one bootable partition |
279 |
#1. n= new disk |
#1. n= new disk |
280 |
#2. p= primary disk |
#2. p= primary disk |
281 |
#3. 1= first partition |
#3. 1= first partition |
282 |
#4. ''= default sector start |
#4. ''= default sector start |
283 |
#5. ''= defaul sector end |
#5. ''= defaul sector end |
284 |
#6. a= bootable flag |
#6. a= bootable flag |
285 |
#7. 1= boot flag for partition 1 |
#7. 1= boot flag for partition 1 |
286 |
#8. w= write/quit |
#8. w= write/quit |
287 |
fdisk ${HDD} &> /dev/null << EOF |
fdisk ${HDD} &> /dev/null << EOF |
288 |
n |
n |
289 |
p |
p |
290 |
1 |
1 |
294 |
1 |
1 |
295 |
w |
w |
296 |
EOF |
EOF |
297 |
|
fi |
298 |
|
else |
299 |
|
cfdisk ${HDD} || dialog_die |
300 |
fi |
fi |
301 |
} |
} |
302 |
|
|
|
setup_hdd_partitions_manual() |
|
|
{ |
|
|
ROOTHDD="${HDD}1" |
|
|
SWAPHDD="" |
|
|
BOOTHDD="" |
|
|
cfdisk ${HDD} || dialog_die |
|
|
} |
|
|
|
|
303 |
setup_hdd_format() |
setup_hdd_format() |
304 |
{ |
{ |
305 |
# sanity check - should not happen |
install -d /tmp |
306 |
if is_mounted --device "${ROOTHDD}" |
:> /tmp/format.log |
307 |
|
|
308 |
|
if [[ -n ${SWAPHDD} ]] |
309 |
then |
then |
310 |
echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 |
# sanity check - should not happen |
311 |
umount "${ROOTHDD}" |
if is_mounted --device "${SWAPHDD}" |
312 |
|
then |
313 |
|
echo "format: device ${SWAPHDD} is already mounted, umount it" >&2 |
314 |
|
umount "${SWAPHDD}" |
315 |
|
fi |
316 |
|
mkswap ${SWAPHDD} || die |
317 |
|
fi |
318 |
|
|
319 |
|
if [[ -n ${BOOTHDD} ]] |
320 |
|
then |
321 |
|
# sanity check - should not happen |
322 |
|
if is_mounted --device "${BOOTHDD}" |
323 |
|
then |
324 |
|
echo "format: device ${BOOTHDD} is already mounted, umount it" >&2 |
325 |
|
umount "${BOOTHDD}" |
326 |
|
fi |
327 |
|
|
328 |
|
mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die |
329 |
fi |
fi |
330 |
|
|
331 |
mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die |
if [[ -n ${ROOTHDD} ]] |
332 |
|
then |
333 |
|
# sanity check - should not happen |
334 |
|
if is_mounted --device "${ROOTHDD}" |
335 |
|
then |
336 |
|
echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 |
337 |
|
umount "${ROOTHDD}" |
338 |
|
fi |
339 |
|
|
340 |
|
mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die |
341 |
|
fi |
342 |
} |
} |
343 |
|
|
344 |
install_system_image() |
install_system_image() |
355 |
# write fstab |
# write fstab |
356 |
CONFIG="${INSTALLROOT}/etc/fstab" |
CONFIG="${INSTALLROOT}/etc/fstab" |
357 |
clearconfig |
clearconfig |
358 |
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" |
if [[ -n ${BOOTHDD} ]] |
359 |
|
then |
360 |
|
addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1" |
361 |
|
fi |
362 |
|
if [[ -n ${ROOTHDD} ]] |
363 |
|
then |
364 |
|
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
365 |
|
fi |
366 |
|
if [[ -n ${SWAPHDD} ]] |
367 |
|
then |
368 |
|
addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" |
369 |
|
fi |
370 |
addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
371 |
addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
372 |
|
|
427 |
if [[ ${retval} -eq 0 ]] |
if [[ ${retval} -eq 0 ]] |
428 |
then |
then |
429 |
case "${mode}" in |
case "${mode}" in |
430 |
"1") run_install_auto ;; |
"1") run_install auto ;; |
431 |
"2") run_install_normal ;; |
"2") run_install normal ;; |
432 |
"") task_setup_system_menu;; |
"") task_setup_system_menu;; |
433 |
esac |
esac |
434 |
fi |
fi |
478 |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
479 |
} |
} |
480 |
|
|
481 |
task_setup_hdd_partitions_manual() |
task_setup_hdd_partitions() |
482 |
{ |
{ |
483 |
local i |
local i |
484 |
local retval |
local retval |
494 |
if [[ ${retval} -eq 0 ]] |
if [[ ${retval} -eq 0 ]] |
495 |
then |
then |
496 |
dialog_setup_hdd_info |
dialog_setup_hdd_info |
497 |
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 |
|
498 |
fi |
fi |
499 |
fi |
fi |
500 |
} |
} |
521 |
done |
done |
522 |
} |
} |
523 |
|
|
524 |
run_install_normal() |
run_install() |
525 |
{ |
{ |
526 |
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 |
|
527 |
|
|
|
umount_rootfs |
|
|
dialog_install_successful |
|
|
} |
|
|
|
|
|
run_install_auto() |
|
|
{ |
|
528 |
task_hardware_detection |
task_hardware_detection |
529 |
|
|
530 |
task_setup_hdd_partitions_auto |
case "${method}" in |
531 |
|
auto) |
532 |
|
export BOOTHDD="" |
533 |
|
export SWAPHDD="" |
534 |
|
export ROOTHDD="${HDD}1" |
535 |
|
export FORMAT_FILESYSTEM_BOOTHDD="" |
536 |
|
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
537 |
|
export INSTALL_METHOD="${method}" |
538 |
|
;; |
539 |
|
normal) |
540 |
|
export BOOTHDD="${HDD}1" |
541 |
|
export SWAPHDD="${HDD}2" |
542 |
|
export ROOTHDD="${HDD}3" |
543 |
|
export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
544 |
|
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
545 |
|
export INSTALL_METHOD="${method}" |
546 |
|
;; |
547 |
|
single) |
548 |
|
export BOOTHDD="" |
549 |
|
export SWAPHDD="" |
550 |
|
export ROOTHDD="${HDD}1" |
551 |
|
export FORMAT_FILESYSTEM_BOOTHDD="" |
552 |
|
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
553 |
|
export INSTALL_METHOD="${method}" |
554 |
|
;; |
555 |
|
flash) |
556 |
|
export BOOTHDD="${HDD}1" |
557 |
|
export SWAPHDD="" |
558 |
|
export ROOTHDD="${HDD}2" |
559 |
|
export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
560 |
|
export FORMAT_FILESYSTEM_ROOTHDD="f2fs" |
561 |
|
export INSTALL_METHOD="${method}" |
562 |
|
;; |
563 |
|
*) |
564 |
|
die "Unknown install method '${method}', aborting." |
565 |
|
;; |
566 |
|
esac |
567 |
|
|
568 |
|
task_setup_hdd_partitions |
569 |
dialog_setup_hdd_format |
dialog_setup_hdd_format |
570 |
setup_hdd_format > /dev/null |
setup_hdd_format > /dev/null |
571 |
mount_rootfs |
mount_rootfs |