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 |
|
|
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 |
# 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 |
{ |
{ |
86 |
exit 1 |
exit 1 |
87 |
} |
} |
88 |
|
|
89 |
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() |
|
90 |
{ |
{ |
91 |
local SHDD="${HDD//\/dev\/}" |
while [[ ${CURRENTLINE} != ${TOTALLINES} ]] |
92 |
|
do |
93 |
messagebox -h $"[ Harddrive partitioning ]" \ |
CURRENTLINE=$(grep -c . /tmp/install.log) |
94 |
$"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!" |
PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES})) |
95 |
|
echo ${PERCENT} |
96 |
|
sleep 1 |
97 |
|
done |
98 |
|
rm -f /tmp/install.log |
99 |
|
return 0 |
100 |
} |
} |
101 |
|
|
102 |
dialog_setup_system_menu() |
mount_rootfs() |
103 |
{ |
{ |
|
local mode |
|
104 |
local retval |
local retval |
105 |
|
|
106 |
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 ]] |
|
107 |
then |
then |
108 |
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 |
|
109 |
fi |
fi |
|
} |
|
110 |
|
|
111 |
dialog_hardware_detection() |
if [[ -n ${ROOTHDD} ]] |
|
{ |
|
|
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} ]] |
|
112 |
then |
then |
113 |
message+="\n" |
if is_mounted --location "${INSTALLROOT}" |
114 |
message+=$"Optical disk drives:\n" |
then |
115 |
for i in ${ALL_CDROMS} |
echo $"${INSTALLROOT} already mounted" >&2 |
116 |
do |
else |
117 |
message+="\Z3${i}\Zn" |
mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
118 |
done |
fi |
|
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 ]] |
|
|
then |
|
|
message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" |
|
119 |
fi |
fi |
120 |
|
|
121 |
messagebox -y 15 -h $"Detected hardware:" "${message}" |
[[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
|
} |
|
|
|
|
|
dialog_setup_hdd_partitions_manual() |
|
|
{ |
|
|
local i |
|
|
local retval |
|
122 |
|
|
123 |
if [[ -z ${ALL_DISKS} ]] |
if [[ -n ${BOOTHDD} ]] |
124 |
then |
then |
125 |
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 ]] |
|
126 |
then |
then |
127 |
dialog_setup_hdd_info |
echo $"${INSTALLROOT}/boot already mounted" >&2 |
128 |
setup_hdd_partitions_manual |
else |
129 |
|
mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" |
130 |
fi |
fi |
131 |
fi |
fi |
132 |
} |
} |
133 |
|
|
134 |
dialog_setup_hdd_partitions_auto() |
umount_rootfs() |
135 |
{ |
{ |
136 |
local i |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
137 |
local retval |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
138 |
|
|
139 |
if [[ -z ${ALL_DISKS} ]] |
if [[ -n ${SWAPHDD} ]] |
140 |
then |
then |
141 |
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 |
|
142 |
fi |
fi |
143 |
} |
} |
144 |
|
|
145 |
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() |
|
146 |
{ |
{ |
147 |
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 |
|
148 |
} |
} |
149 |
|
|
|
################################################# |
|
|
# Install Komandos # |
|
|
################################################# |
|
150 |
run_hardware_detection() |
run_hardware_detection() |
151 |
{ |
{ |
152 |
local hwinfo |
local hwinfo |
153 |
|
|
154 |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
155 |
|
|
156 |
## check for special devices/clients: |
# check for special devices/clients: |
157 |
## 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 |
158 |
#local removable=0 |
local removable=0 |
159 |
#if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
160 |
#then |
then |
161 |
#for i in /sys/block/[hs]d*/removable |
#for i in /sys/block/[hs]d*/removable |
162 |
#do |
#do |
163 |
#if [[ $(< ${i}) = 1 ]] |
# if [[ $(< ${i}) = 1 ]] |
164 |
#then |
# then |
165 |
#removable=1 |
# removable=1 |
166 |
#fi |
# fi |
167 |
#done |
#done |
168 |
## smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
# smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
169 |
|
|
170 |
## 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 |
171 |
#export GRUBLEGACYOPTS="rootdelay=8" |
export GRUBLEGACYOPTS="rootdelay=8" |
172 |
## 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 |
173 |
#if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
174 |
#then |
then |
175 |
#export SPECIALDEVICE="zotac_nvidia" |
export SPECIALDEVICE="zotac_nvidia" |
176 |
#else |
else |
177 |
#export SPECIALDEVICE="zotac_intel" |
export SPECIALDEVICE="zotac_intel" |
178 |
#fi |
fi |
179 |
#fi |
fi |
180 |
|
|
181 |
# check for special devices/clients: |
# check for special devices/clients: |
182 |
# 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 |
212 |
# all disks but exclude ramdisks |
# all disks but exclude ramdisks |
213 |
export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') |
export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') |
214 |
# remove the boot device from ALL_DISKS if it was an usbstick |
# remove the boot device from ALL_DISKS if it was an usbstick |
215 |
if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
216 |
then |
then |
217 |
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') |
218 |
export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
219 |
fi |
fi |
220 |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
221 |
} |
} |
222 |
|
|
223 |
hdd_size_below_256mb() |
setup_hdd_partitions() |
224 |
{ |
{ |
|
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" |
|
|
|
|
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 hdd_size_below_256mb ${HDD} |
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 |
fi |
318 |
|
|
319 |
mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die |
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 |
install_mount_rootfs() |
mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die |
329 |
{ |
fi |
330 |
is_mounted --location "${INSTALLROOT}" || mount "${ROOTHDD}" "${INSTALLROOT}" |
|
331 |
install -d ${INSTALLROOT}/boot || 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() |
345 |
{ |
{ |
346 |
pushd ${INSTALLROOT} > /dev/null |
pushd ${INSTALLROOT} > /dev/null |
347 |
tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT} |
tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT} |
348 |
popd > /dev/null |
popd > /dev/null |
349 |
} |
} |
350 |
|
|
351 |
install_bootsector_chroot() |
install_system_settings() |
352 |
{ |
{ |
353 |
local my_roothdd |
local CONFIG |
|
local grubconf=${INSTALLROOT}/boot/grub/grub.conf |
|
|
local grub2conf=/boot/grub/grub.cfg |
|
354 |
|
|
355 |
# check for grub2 |
# write fstab |
356 |
if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]] |
CONFIG="${INSTALLROOT}/etc/fstab" |
357 |
|
clearconfig |
358 |
|
if [[ -n ${BOOTHDD} ]] |
359 |
then |
then |
360 |
# needed by grub-mkconfig on the first run |
addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1" |
361 |
if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]] |
fi |
362 |
then |
if [[ -n ${ROOTHDD} ]] |
363 |
install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die |
then |
364 |
fi |
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
365 |
|
fi |
366 |
# set kernelopts |
if [[ -n ${SWAPHDD} ]] |
367 |
if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]] |
then |
368 |
then |
addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" |
369 |
sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die |
fi |
370 |
else |
addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
371 |
echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLROOT}/etc/conf.d/grub || dialog_die |
addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
|
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 |
|
372 |
|
|
373 |
#for alx only |
# install network config skeleton |
374 |
if [ -e ${INSTALLROOT}/etc/alx_version ] |
CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0" |
375 |
|
clearconfig |
376 |
|
addconfig 'ONBOOT="yes"' |
377 |
|
addconfig 'NETWORKING="dhcp"' |
378 |
|
|
379 |
|
# intel framebuffer quirk |
380 |
|
CONFIG="${INSTALLROOT}/etc/splash/splash.conf" |
381 |
|
if [ -e ${CONFIG} ] && [ -e /proc/fb ] |
382 |
|
then |
383 |
|
if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
384 |
then |
then |
385 |
OLD_ALXVER="${ALXVER}" |
fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
386 |
source ${INSTALLROOT}/etc/alx_version |
[[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die |
|
KRNVER="ALX-${ALXVER}" |
|
|
ALXVER="${OLD_ALXVER}" |
|
387 |
fi |
fi |
388 |
|
fi |
389 |
|
} |
390 |
|
|
|
[[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" |
|
|
[[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" |
|
|
[[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" |
|
391 |
|
|
392 |
# uuid support |
### installer dialogs ### |
|
if is_uuid_supported |
|
|
then |
|
|
my_roothdd="UUID=$(get_uuid ${ROOTHDD})" |
|
|
else |
|
|
my_roothdd="${ROOTHDD}" |
|
|
fi |
|
393 |
|
|
394 |
: > ${grubconf} || dialog_die |
dialog_die() |
395 |
echo "default 0" >> ${grubconf} || dialog_die |
{ |
396 |
echo "timeout 3" >> ${grubconf} || dialog_die |
ERROR="$1" |
397 |
# using current root password |
RETVAL="$?" |
398 |
echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || dialog_die |
dialog_install_failure |
399 |
|
exit 1 |
400 |
|
} |
401 |
|
|
402 |
echo >> ${grubconf} || dialog_die |
dialog_warning() |
403 |
echo "# normal boot" >> ${grubconf} || dialog_die |
{ |
404 |
echo "title ${KRNVER}" >> ${grubconf} || dialog_die |
local retval |
|
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 |
|
405 |
|
|
406 |
echo >> ${grubconf} || dialog_die |
yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?" |
407 |
echo "# admin boot" >> ${grubconf} || dialog_die |
retval=$? |
408 |
echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die |
if [[ ${retval} -eq 1 ]] |
409 |
echo "lock" >> ${grubconf} || dialog_die |
then |
410 |
echo "root (hd0,0)" >> ${grubconf} || dialog_die |
clear |
411 |
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die |
echo $"The process was aborted." |
412 |
if is_initrd_supported |
exit 1 |
413 |
then |
fi |
414 |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die |
} |
|
fi |
|
415 |
|
|
|
echo >> ${grubconf} || dialog_die |
|
|
echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die |
|
|
echo "lock" >> ${grubconf} || dialog_die |
|
|
echo "root (hd0,0)" >> ${grubconf} || dialog_die |
|
|
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die |
|
|
if is_initrd_supported |
|
|
then |
|
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die |
|
|
fi |
|
416 |
|
|
417 |
# bootsector schreiben chrooted schreiben (lfs/magellan) |
### installer tasks ### |
|
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 |
|
418 |
|
|
419 |
# run installrc |
task_setup_system_menu() |
420 |
chrooted /bin/bash --rcfile /root/.installrc -i |
{ |
421 |
rm ${INSTALLROOT}/root/.installrc |
local mode |
422 |
} |
local retval |
|
|
|
|
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 |
|
423 |
|
|
424 |
if [[ ${FORMFACTOR} = laptop ]] |
mode="$(dialog_setup_system_menu)" |
425 |
|
retval=$? |
426 |
|
[[ ${retval} -eq 1 ]] && return 1 |
427 |
|
if [[ ${retval} -eq 0 ]] |
428 |
then |
then |
429 |
OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" |
case "${mode}" in |
430 |
|
"1") run_install auto ;; |
431 |
|
"2") run_install normal ;; |
432 |
|
"") task_setup_system_menu;; |
433 |
|
esac |
434 |
fi |
fi |
435 |
|
} |
436 |
|
|
437 |
# install an appropriate uvesafb.conf |
task_hardware_detection() |
438 |
install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die |
{ |
439 |
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die |
local message |
440 |
|
|
441 |
# install an appropriate viafb.conf |
run_hardware_detection_disks |
|
echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die |
|
442 |
|
|
443 |
# install an appropriate i810fb.conf |
message+=$"Harddrives:\n" |
|
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 |
|
444 |
|
|
445 |
cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF |
if [[ ! -z ${ALL_DISKS} ]] |
446 |
echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd |
then |
447 |
mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
for i in ${ALL_DISKS} |
448 |
exit 0 |
do |
449 |
CHROOTEOF |
message+="\Z3${i}\Zn " |
450 |
|
done |
451 |
|
message+="\n" |
452 |
|
fi |
453 |
|
|
454 |
# run installrc |
if [[ ! -z ${ALL_CDROMS} ]] |
455 |
chrooted /bin/bash --rcfile /root/.installrc -i |
then |
456 |
rm ${INSTALLROOT}/root/.installrc |
message+="\n" |
457 |
} |
message+=$"Optical disk drives:\n" |
458 |
|
for i in ${ALL_CDROMS} |
459 |
|
do |
460 |
|
message+="\Z3${i}\Zn" |
461 |
|
done |
462 |
|
message+="\n" |
463 |
|
fi |
464 |
|
|
465 |
is_uuid_supported() |
# other devices |
466 |
{ |
run_hardware_detection |
467 |
if [[ -x $(type -P busybox.mkinitrd) ]] |
case "${SPECIALDEVICE}" in |
468 |
|
zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; |
469 |
|
rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; |
470 |
|
maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; |
471 |
|
*) message+=$"\n\ZnCommon device detected.\Zn" ;; |
472 |
|
esac |
473 |
|
if [[ ${FORMFACTOR} = laptop ]] |
474 |
then |
then |
475 |
# only detect uuids if supported |
message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" |
|
if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] |
|
|
then |
|
|
return 0 |
|
|
fi |
|
476 |
fi |
fi |
477 |
|
|
478 |
return 1 |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
479 |
} |
} |
480 |
|
|
481 |
install_system_settings() |
task_setup_hdd_partitions() |
482 |
{ |
{ |
483 |
# schreibe fstab |
local i |
484 |
if is_uuid_supported |
local retval |
|
then |
|
|
echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
|
|
else |
|
|
echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
|
|
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 |
|
|
|
|
|
# install network config skeleton |
|
|
install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die |
|
485 |
|
|
486 |
# intel framebufer quirk |
if [[ -z ${ALL_DISKS} ]] |
|
if [[ -e /proc/fb ]] |
|
487 |
then |
then |
488 |
if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
dialog_no_harddrive_found |
489 |
|
exit 1 |
490 |
|
else |
491 |
|
HDD=$(dialog_select_target_harddrive) |
492 |
|
retval=$? |
493 |
|
[[ ${retval} -eq 1 ]] && return 1 |
494 |
|
if [[ ${retval} -eq 0 ]] |
495 |
then |
then |
496 |
fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
dialog_setup_hdd_info |
497 |
if [[ ${fbdev} != 0 ]] |
setup_hdd_partitions |
|
then |
|
|
sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die |
|
|
fi |
|
498 |
fi |
fi |
499 |
fi |
fi |
500 |
} |
} |
501 |
|
|
502 |
install_umount_rootfs() |
task_main() |
503 |
{ |
{ |
504 |
is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot |
local method=0 |
505 |
is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} |
local retval |
|
} |
|
506 |
|
|
507 |
install_do_reboot() |
while [[ ${method} -le 2 ]] |
508 |
{ |
do |
509 |
reboot |
method=$(dialog_main) |
510 |
|
retval=$? |
511 |
|
[[ ${retval} -eq 1 ]] && exit 1 |
512 |
|
if [[ ${retval} -eq 0 ]] |
513 |
|
then |
514 |
|
case ${method} in |
515 |
|
"1") task_setup_system_menu ;; |
516 |
|
"2") task_hardware_detection ;; |
517 |
|
"3") install_do_reboot ;; |
518 |
|
"4") /bin/bash --login -i ;; |
519 |
|
esac |
520 |
|
fi |
521 |
|
done |
522 |
} |
} |
523 |
|
|
524 |
################################################# |
run_install() |
|
# Install Ablauf Scripte # |
|
|
################################################# |
|
|
|
|
|
run_install_normal() |
|
525 |
{ |
{ |
526 |
dialog_hardware_detection |
local method="$1" |
527 |
|
|
528 |
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 |
|
529 |
|
|
530 |
dialog_install_settings |
case "${method}" in |
531 |
sleep 1 |
auto) |
532 |
install_system_settings |
export BOOTHDD="" |
533 |
if is_initrd_supported |
export SWAPHDD="" |
534 |
then |
export ROOTHDD="${HDD}1" |
535 |
dialog_install_initrd |
export FORMAT_FILESYSTEM_BOOTHDD="" |
536 |
initrd_config |
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
537 |
initrd_install |
export INSTALL_METHOD="${method}" |
538 |
fi |
;; |
539 |
|
normal) |
540 |
dialog_install_bootsector |
export BOOTHDD="${HDD}1" |
541 |
bootloader_config |
export SWAPHDD="${HDD}2" |
542 |
bootloader_install |
export ROOTHDD="${HDD}3" |
543 |
|
export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
544 |
install_umount_rootfs |
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
545 |
dialog_install_successful |
export INSTALL_METHOD="${method}" |
546 |
} |
;; |
547 |
|
single) |
548 |
run_install_auto() |
export BOOTHDD="" |
549 |
{ |
export SWAPHDD="" |
550 |
dialog_hardware_detection |
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 |
dialog_setup_hdd_partitions_auto |
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 |
install_mount_rootfs |
mount_rootfs |
572 |
(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 |
573 |
|
|
574 |
dialog_install_settings |
dialog_install_settings |
585 |
bootloader_config |
bootloader_config |
586 |
bootloader_install |
bootloader_install |
587 |
|
|
588 |
install_umount_rootfs |
umount_rootfs |
589 |
dialog_install_successful |
dialog_install_successful |
590 |
} |
} |
591 |
|
|
592 |
# set some proper traps |
# set some proper traps |
593 |
trap "trap_exit" SIGINT SIGQUIT |
trap "trap_exit" SIGINT SIGQUIT |
594 |
|
|
595 |
dialog_main |
task_main |
596 |
|
|
597 |
exit 0 |
exit 0 |