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}" |
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 |
|
|
99 |
return 0 |
return 0 |
100 |
} |
} |
101 |
|
|
102 |
|
install_mount_rootfs() |
103 |
|
{ |
104 |
|
local opts |
105 |
|
|
106 |
|
if [[ -n ${SWAPHDD} ]] |
107 |
|
then |
108 |
|
swapon ${SWAPHDD} || die |
109 |
|
fi |
110 |
|
if [[ -n ${ROOTHDD} ]] |
111 |
|
then |
112 |
|
mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die |
113 |
|
fi |
114 |
|
if [[ -n ${BOOTHDD} ]] |
115 |
|
then |
116 |
|
install -d ${INSTALL_ROOT}/boot || die |
117 |
|
mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die |
118 |
|
fi |
119 |
|
|
120 |
|
cd ${INSTALL_ROOT} || die |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
mount_rootfs() |
mount_rootfs() |
125 |
{ |
{ |
126 |
local retval |
local retval |
127 |
|
|
128 |
if is_mounted --location "${INSTALLROOT}" |
if [[ -n ${SWAPHDD} ]] |
129 |
then |
then |
130 |
echo $"${INSTALLROOT} already mounted" >&2 |
swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'" |
131 |
else |
fi |
132 |
mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
|
133 |
|
if [[ -n ${ROOTHDD} ]] |
134 |
|
then |
135 |
|
if is_mounted --location "${INSTALLROOT}" |
136 |
|
then |
137 |
|
echo $"${INSTALLROOT} already mounted" >&2 |
138 |
|
else |
139 |
|
mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
140 |
|
fi |
141 |
fi |
fi |
142 |
|
|
143 |
[[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
[[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
144 |
|
|
145 |
|
if [[ -n ${BOOTHDD} ]] |
146 |
|
then |
147 |
|
if is_mounted --location "${INSTALLROOT}"/boot |
148 |
|
then |
149 |
|
echo $"${INSTALLROOT}/boot already mounted" >&2 |
150 |
|
else |
151 |
|
mount "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" |
152 |
|
fi |
153 |
|
fi |
154 |
} |
} |
155 |
|
|
156 |
umount_rootfs() |
umount_rootfs() |
157 |
{ |
{ |
158 |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
159 |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
160 |
|
|
161 |
|
if [[ -n ${SWAPHDD} ]] |
162 |
|
then |
163 |
|
swapoff ${SWAPHDD} || die |
164 |
|
fi |
165 |
} |
} |
166 |
|
|
167 |
install_do_reboot() |
install_do_reboot() |
175 |
|
|
176 |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
177 |
|
|
178 |
## check for special devices/clients: |
# check for special devices/clients: |
179 |
## 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 |
180 |
#local removable=0 |
local removable=0 |
181 |
#if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
182 |
#then |
then |
183 |
#for i in /sys/block/[hs]d*/removable |
#for i in /sys/block/[hs]d*/removable |
184 |
#do |
#do |
185 |
#if [[ $(< ${i}) = 1 ]] |
# if [[ $(< ${i}) = 1 ]] |
186 |
#then |
# then |
187 |
#removable=1 |
# removable=1 |
188 |
#fi |
# fi |
189 |
#done |
#done |
190 |
## smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
# smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
191 |
|
|
192 |
## 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 |
193 |
#export GRUBLEGACYOPTS="rootdelay=8" |
export GRUBLEGACYOPTS="rootdelay=8" |
194 |
## 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 |
195 |
#if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
196 |
#then |
then |
197 |
#export SPECIALDEVICE="zotac_nvidia" |
export SPECIALDEVICE="zotac_nvidia" |
198 |
#else |
else |
199 |
#export SPECIALDEVICE="zotac_intel" |
export SPECIALDEVICE="zotac_intel" |
200 |
#fi |
fi |
201 |
#fi |
fi |
202 |
|
|
203 |
# check for special devices/clients: |
# check for special devices/clients: |
204 |
# 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 |
234 |
# all disks but exclude ramdisks |
# all disks but exclude ramdisks |
235 |
export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') |
export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') |
236 |
# remove the boot device from ALL_DISKS if it was an usbstick |
# remove the boot device from ALL_DISKS if it was an usbstick |
237 |
if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
238 |
then |
then |
239 |
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') |
240 |
export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
241 |
fi |
fi |
242 |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
243 |
} |
} |
244 |
|
|
245 |
setup_hdd_partitions_auto() |
setup_hdd_partitions() |
246 |
{ |
{ |
247 |
ROOTHDD="${HDD}1" |
case "${INSTALL_METHOD}" in |
248 |
|
auto) |
249 |
|
BOOTHDD="" |
250 |
|
SWAPHDD="" |
251 |
|
ROOTHDD="${HDD}1" |
252 |
|
;; |
253 |
|
normal) |
254 |
|
BOOTHDD="${HDD}1" |
255 |
|
SWAPHDD="${HDD}2" |
256 |
|
ROOTHDD="${HDD}3" |
257 |
|
;; |
258 |
|
esac |
259 |
|
|
260 |
# sanity check - should not happen |
# sanity check - should not happen |
261 |
if is_mounted --device "${ROOTHDD}" |
if is_mounted --device "${ROOTHDD}" |
263 |
echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 |
echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 |
264 |
umount "${ROOTHDD}" |
umount "${ROOTHDD}" |
265 |
fi |
fi |
266 |
|
if [[ -n ${BOOTHDD} ]] |
|
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
|
|
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
|
267 |
then |
then |
268 |
if device_minimum_size "${HDD}" 256 |
if is_mounted --device "${BOOTHDD}" |
269 |
then |
then |
270 |
FDISKPARTIONBELOW256MB=1 |
echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2 |
271 |
else |
umount "${BOOTHDD}" |
|
FDISKPARTIONBELOW256MB=0 |
|
272 |
fi |
fi |
273 |
fi |
fi |
274 |
|
|
275 |
## delete disk |
if [[ ${INSTALL_METHOD} = auto ]] |
|
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
|
|
|
|
|
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
|
276 |
then |
then |
277 |
## setup one bootable partition |
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
278 |
#1. n= new disk |
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
279 |
#2. p= primary disk |
then |
280 |
#3. 1= first partition |
if device_minimum_size "${HDD}" 256 |
281 |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
then |
282 |
#5. ''= defaul sector end |
FDISKPARTIONBELOW256MB=1 |
283 |
#6. a= bootable flag |
else |
284 |
#7. 1= boot flag for partition 1 |
FDISKPARTIONBELOW256MB=0 |
285 |
#8. w= write/quit |
fi |
286 |
fdisk ${HDD} &> /dev/null << EOF |
fi |
287 |
|
|
288 |
|
## delete disk |
289 |
|
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
290 |
|
|
291 |
|
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
292 |
|
then |
293 |
|
## setup one bootable partition |
294 |
|
#1. n= new disk |
295 |
|
#2. p= primary disk |
296 |
|
#3. 1= first partition |
297 |
|
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
298 |
|
#5. ''= defaul sector end |
299 |
|
#6. a= bootable flag |
300 |
|
#7. 1= boot flag for partition 1 |
301 |
|
#8. w= write/quit |
302 |
|
fdisk ${HDD} &> /dev/null << EOF |
303 |
n |
n |
304 |
p |
p |
305 |
1 |
1 |
309 |
1 |
1 |
310 |
w |
w |
311 |
EOF |
EOF |
312 |
else |
else |
313 |
## setup one bootable partition |
## setup one bootable partition |
314 |
#1. n= new disk |
#1. n= new disk |
315 |
#2. p= primary disk |
#2. p= primary disk |
316 |
#3. 1= first partition |
#3. 1= first partition |
317 |
#4. ''= default sector start |
#4. ''= default sector start |
318 |
#5. ''= defaul sector end |
#5. ''= defaul sector end |
319 |
#6. a= bootable flag |
#6. a= bootable flag |
320 |
#7. 1= boot flag for partition 1 |
#7. 1= boot flag for partition 1 |
321 |
#8. w= write/quit |
#8. w= write/quit |
322 |
fdisk ${HDD} &> /dev/null << EOF |
fdisk ${HDD} &> /dev/null << EOF |
323 |
n |
n |
324 |
p |
p |
325 |
1 |
1 |
329 |
1 |
1 |
330 |
w |
w |
331 |
EOF |
EOF |
332 |
|
fi |
333 |
|
else |
334 |
|
cfdisk ${HDD} || dialog_die |
335 |
fi |
fi |
336 |
} |
} |
337 |
|
|
|
setup_hdd_partitions_manual() |
|
|
{ |
|
|
ROOTHDD="${HDD}1" |
|
|
SWAPHDD="" |
|
|
BOOTHDD="" |
|
|
cfdisk ${HDD} || dialog_die |
|
|
} |
|
|
|
|
338 |
setup_hdd_format() |
setup_hdd_format() |
339 |
{ |
{ |
340 |
# sanity check - should not happen |
if [[ -n ${SWAPHDD} ]] |
|
if is_mounted --device "${ROOTHDD}" |
|
341 |
then |
then |
342 |
echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 |
# sanity check - should not happen |
343 |
umount "${ROOTHDD}" |
if is_mounted --device "${SWAPHDD}" |
344 |
|
then |
345 |
|
echo "format: device ${SWAPHDD} is already mounted, umount it" >&2 |
346 |
|
umount "${SWAPHDD}" |
347 |
|
fi |
348 |
|
mkswap ${SWAPHDD} || die |
349 |
fi |
fi |
350 |
|
|
351 |
mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die |
if [[ -n ${BOOTHDD} ]] |
352 |
|
then |
353 |
|
# sanity check - should not happen |
354 |
|
if is_mounted --device "${BOOTHDD}" |
355 |
|
then |
356 |
|
echo "format: device ${BOOTHDD} is already mounted, umount it" >&2 |
357 |
|
umount "${BOOTHDD}" |
358 |
|
fi |
359 |
|
|
360 |
|
mkfs."${FORMAT_FILESYSTEM}" -q "${BOOTHDD}" || dialog_die |
361 |
|
fi |
362 |
|
|
363 |
|
if [[ -n ${ROOTHDD} ]] |
364 |
|
then |
365 |
|
# sanity check - should not happen |
366 |
|
if is_mounted --device "${ROOTHDD}" |
367 |
|
then |
368 |
|
echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 |
369 |
|
umount "${ROOTHDD}" |
370 |
|
fi |
371 |
|
|
372 |
|
mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die |
373 |
|
fi |
374 |
} |
} |
375 |
|
|
376 |
install_system_image() |
install_system_image() |
377 |
{ |
{ |
378 |
pushd ${INSTALLROOT} > /dev/null |
pushd ${INSTALLROOT} > /dev/null |
379 |
tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT} |
tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT} |
380 |
popd > /dev/null |
popd > /dev/null |
381 |
} |
} |
382 |
|
|
387 |
# write fstab |
# write fstab |
388 |
CONFIG="${INSTALLROOT}/etc/fstab" |
CONFIG="${INSTALLROOT}/etc/fstab" |
389 |
clearconfig |
clearconfig |
390 |
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" |
if [[ -n ${BOOTHDD} ]] |
391 |
|
then |
392 |
|
addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t1 1" |
393 |
|
fi |
394 |
|
if [[ -n ${ROOTHDD} ]] |
395 |
|
then |
396 |
|
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" |
397 |
|
fi |
398 |
|
if [[ -n ${SWAPHDD} ]] |
399 |
|
then |
400 |
|
addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" |
401 |
|
fi |
402 |
addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
403 |
addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
404 |
|
|
459 |
if [[ ${retval} -eq 0 ]] |
if [[ ${retval} -eq 0 ]] |
460 |
then |
then |
461 |
case "${mode}" in |
case "${mode}" in |
462 |
"1") run_install_auto ;; |
"1") run_install auto ;; |
463 |
"2") run_install_normal ;; |
"2") run_install normal ;; |
464 |
"") task_setup_system_menu;; |
"") task_setup_system_menu;; |
465 |
esac |
esac |
466 |
fi |
fi |
510 |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
511 |
} |
} |
512 |
|
|
513 |
task_setup_hdd_partitions_manual() |
task_setup_hdd_partitions() |
514 |
{ |
{ |
515 |
local i |
local i |
516 |
local retval |
local retval |
526 |
if [[ ${retval} -eq 0 ]] |
if [[ ${retval} -eq 0 ]] |
527 |
then |
then |
528 |
dialog_setup_hdd_info |
dialog_setup_hdd_info |
529 |
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 |
|
530 |
fi |
fi |
531 |
fi |
fi |
532 |
} |
} |
553 |
done |
done |
554 |
} |
} |
555 |
|
|
556 |
run_install_normal() |
run_install() |
557 |
{ |
{ |
558 |
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 |
|
559 |
|
|
|
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 |
|
|
} |
|
|
|
|
|
run_install_auto() |
|
|
{ |
|
560 |
task_hardware_detection |
task_hardware_detection |
561 |
|
|
562 |
task_setup_hdd_partitions_auto |
case "${method}" in |
563 |
|
auto) |
564 |
|
export INSTALL_METHOD="${method}" |
565 |
|
;; |
566 |
|
normal) |
567 |
|
export INSTALL_METHOD="${method}" |
568 |
|
;; |
569 |
|
*) |
570 |
|
die "Unknown install method '${method}', aborting." |
571 |
|
;; |
572 |
|
esac |
573 |
|
|
574 |
|
task_setup_hdd_partitions |
575 |
dialog_setup_hdd_format |
dialog_setup_hdd_format |
576 |
setup_hdd_format > /dev/null |
setup_hdd_format > /dev/null |
577 |
mount_rootfs |
mount_rootfs |