This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfedora-installer
executable file
·649 lines (558 loc) · 19.7 KB
/
fedora-installer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
#! /bin/bash
# *****************************
# Version 34.2
# *****************************
# Fedora image read url as parameter
FEDORAURL=${1:-"https://download.fedoraproject.org/pub/fedora/linux/releases/34/Workstation/aarch64/images/Fedora-Workstation-34-1.2.aarch64.raw.xz"}
FEDORARAW="$(basename -s .xz "${FEDORAURL}")"
# Set globals
TMPDIR=/var/tmp/fedora-installer
MEDIADIR=/var/tmp/fedora-installer-media
ARCH='aarch64'
CARCH=$(uname -m)
# systemd-nspawn --resolv-conf has been buggy. If you have issues you can try,
# --resolv-conf=auto --resolv-conf=copy-host or --bind-ro=/etc/resolv.conf
# It all depends how resolv.conf is managed on host and in image.
#NSPAWN='systemd-nspawn -q --resolv-conf=auto --timezone=off -D'
NSPAWN='systemd-nspawn -q --bind-ro=/etc/resolv.conf --timezone=off -D'
LOOP=$(losetup -f)
# set colorscheme
export DIALOGRC="./dialogrc_gui"
# clearing variables
DEVICE="Pinebook Pro"
EDITION="Fedora Workstation"
USER=""
USERGROUPS=""
FULLNAME=""
PASSWORD=""
CONFIRMPASSWORD=""
CONFIRMROOTPASSWORD=""
ROOTPASSWORD=""
SDCARD=""
SDTYP=""
SDDEV=""
DEV_NAME=""
TIMEZONE=""
LOCALE=""
HOSTNAME=""
DISKLAYOUT=""
DNFUPGRADE=""
# check if root
if [ "$EUID" -ne 0 ]; then
echo "*******************************************************************************************"
echo "* *"
echo "* This script requires root permissions to run. Please run as root or with sudo! *"
echo "* *"
echo "*******************************************************************************************"
exit
fi
# Sanity checks for dependencies
declare -a DEPENDNECIES=( "btrfs" "sed" "rsync" "systemd-nspawn" "wget" "dialog" "openssl" "awk" "fdisk" "sfdisk" )
for i in "${DEPENDNECIES[@]}"; do
if ! [[ -f "/bin/$i" || -f "/sbin/$i" || -f "/usr/bin/$i" || -f "/usr/sbin/$i" ]] ; then
echo "$i command is missing! Please install the relevant package."
exit 1
fi
done
if [[ "$CARCH" != "aarch64" ]]; then
if ! [[ -f "/usr/lib/binfmt.d/qemu-aarch64-static.conf" || -f "/usr/lib/binfmt.d/qemu-static.conf" ]]; then
echo "qemu-aarch64-static.conf file is missing. Please install the relevant package."
exit 1
fi
fi
# Functions
msg() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
GREEN="${BOLD}\e[1;32m"
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
info() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
BLUE="${BOLD}\e[1;34m"
local mesg=$1; shift
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
}
usage_build_installer() {
echo "Usage: ${0##*/} [options]"
echo ' -h This help'
echo ''
echo ''
exit $1
}
get_timer(){
echo $(date +%s)
}
# $1: start timer
elapsed_time(){
echo $(echo $1 $(get_timer) | awk '{ printf "%0.2f",($2-$1)/60 }')
}
show_elapsed_time(){
msg "Time %s: %s minutes..." "$1" "$(elapsed_time $2)"
}
prepare_media() {
msg "Prepare source media..."
# fetch and extract fedora image
if [ ! -f "$MEDIADIR/$FEDORARAW" ]; then
info "Downloading Fedora Image..."
wget -q --show-progress --progress=bar:force:noscroll $FEDORAURL --output-document $MEDIADIR/$FEDORARAW.xz || exit
info "Decompress Fedora Image..."
xz --decompress $MEDIADIR/$FEDORARAW.xz
fi
}
install_fedora() {
msg "Install Fedora from media..."
info "Making mount directories..."
mkdir -p $TMPDIR/imgfs/{2,3}
info "Mounting Fedora image..."
losetup $LOOP $MEDIADIR/$FEDORARAW
partprobe -s $LOOP
mount "$LOOP"p2 $TMPDIR/imgfs/2
mount "$LOOP"p3 $TMPDIR/imgfs/3
info "Copying Fedora files (progress status sucks)..."
if [[ $(blkid -s TYPE -o value "$LOOP"p3) = btrfs ]]; then
rsync -a --info=progress2 $TMPDIR/imgfs/3/root/* $TMPDIR/root/
else
rsync -a --info=progress2 $TMPDIR/imgfs/3/* $TMPDIR/root/
fi
rsync -a --info=progress2 $TMPDIR/imgfs/2/* $TMPDIR/root/boot/
info "Unmounting Fedora media..."
umount "$LOOP"p2
umount "$LOOP"p3
losetup -d $LOOP
info "Deleting temp directories..."
rmdir $TMPDIR/imgfs/2
rmdir $TMPDIR/imgfs/3
rmdir $TMPDIR/imgfs
}
upgrade_fedora() {
msg "Upgrade Fedora and add packages..."
info "Remove packages not needed..."
$NSPAWN $TMPDIR/root dnf remove -y kernel kernel-core kernel-modules 1> /dev/null 2>&1
rm -f $TMPDIR/root/etc/dnf/protected.d/grub2-*
$NSPAWN $TMPDIR/root dnf remove -y grub2-* efi-filesystem bcm283x-firmware 1> /dev/null 2>&1
rm -rf $TMPDIR/root/boot/*
mkdir -p $TMPDIR/dnf
mount -o bind $TMPDIR/dnf $TMPDIR/root/var/cache/dnf
if [[ "$DNFUPGRADE" = "yes" ]]; then
info "Upgrade Fedora..."
$NSPAWN $TMPDIR/root dnf upgrade -y --refresh
else
info "No upgrade..."
fi
if [[ $FEDORAURL == *"Minimal"* ]]; then
$NSPAWN $TMPDIR/root dnf install -y NetworkManager-tui
fi
info "Enable copr/aptupdate/pinebook-pro..."
$NSPAWN $TMPDIR/root dnf copr enable -y aptupdate/pinebook-pro
$NSPAWN $TMPDIR/root dnf makecache
info "Install Pinebook Pro copr packages..."
if [[ "$KERNELVER" = "kernel-pbp" ]]; then
$NSPAWN $TMPDIR/root dnf install -y kernel-pbp uboot-pinebookpro pinebookpro-extlinux ap6256-firmware pbp-keyboard-hwdb pinebookpro-suspend pinebookpro-audio pinebookpro-network
else
# KERNELVER=linux-majaro
$NSPAWN $TMPDIR/root dnf install -y linux-manjaro uboot-pinebookpro pinebookpro-extlinux ap6256-firmware pbp-keyboard-hwdb pinebookpro-suspend pinebookpro-audio pinebookpro-network
fi
info "Clear dnf cache..."
umount $TMPDIR/root/var/cache/dnf
$NSPAWN $TMPDIR/root dnf clean all 1> /dev/null 2>&1
}
configure_fedora() {
msg "Configure Fedora..."
info "Run SELinux autorelabel first boot..."
touch $TMPDIR/root/.autorelabel
# Get UUID
BOOTUUID=$(blkid -s UUID -o value "${SDCARD}${SDDEV}1")
ROOTUUID=$(blkid -s UUID -o value "${SDCARD}${SDDEV}2")
if [[ "$DISKLAYOUT" = "ext4" ]]; then
# Configure extlinux.conf
info "Update extlinux.conf with UUID..."
mkdir ${TMPDIR}/root/boot/extlinux/ -p
echo "LABEL Fedora PinebookPro" > ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "KERNEL /Image" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "FDT /dtbs/rockchip/rk3399-pinebook-pro.dtb" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "INITRD /initramfs-linux.img" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "APPEND console=tty1 console=ttyS2,1500000 root=UUID=${ROOTUUID} rw splash plymouth.ignore-serial-consoles rhgb quiet" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
info "Update fstab with UUID..."
# Edit fstab
echo "UUID=${ROOTUUID} / ext4 defaults 0 1" > $TMPDIR/root/etc/fstab
echo "UUID=${BOOTUUID} /boot ext4 defaults 0 2" >> $TMPDIR/root/etc/fstab
else
# DISKLAYOUT = btrfs
info "Update extlinux.conf with UUID..."
# Configure extlinux.conf
mkdir ${TMPDIR}/root/boot/extlinux/ -p
echo "LABEL Fedora PinebookPro" > ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "KERNEL /Image" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "FDT /dtbs/rockchip/rk3399-pinebook-pro.dtb" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "INITRD /initramfs-linux.img" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
echo "APPEND console=tty1 console=ttyS2,1500000 root=UUID=${ROOTUUID} rw rootflags=subvol=root splash plymouth.ignore-serial-consoles rhgb quiet" >> ${TMPDIR}/root/boot/extlinux/extlinux.conf
info "Update fstab with UUID..."
# Edit fstab
echo "UUID=${ROOTUUID} / btrfs subvol=root,compress=zstd:1,noatime 0 0" > $TMPDIR/root/etc/fstab
echo "UUID=${BOOTUUID} /boot ext4 defaults 1 2" >> $TMPDIR/root/etc/fstab
echo "UUID=${ROOTUUID} /home btrfs subvol=home,compress=zstd:1,noatime 0 0" >> $TMPDIR/root/etc/fstab
fi
info "Set timezone..."
$NSPAWN $TMPDIR/root ln -sf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime 1> /dev/null 2>&1
info "Set locale..."
echo "LANG=$LOCALE" | tee --append $TMPDIR/root/etc/locale.conf 1> /dev/null 2>&1
info "Set keymap..."
echo "KEYMAP=$CLIKEYMAP" | tee --append $TMPDIR/root/etc/vconsole.conf 1> /dev/null 2>&1
echo 'Section "InputClass"' > $TMPDIR/root/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'Identifier "system-keyboard"' >> $TMPDIR/root/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'Option "XkbLayout" "us"' >> $TMPDIR/root/etc/X11/xorg.conf.d/00-keyboard.conf
echo 'EndSection' >> $TMPDIR/root/etc/X11/xorg.conf.d/00-keyboard.conf
sed -i s/"us"/"$X11KEYMAP"/ $TMPDIR/root/etc/X11/xorg.conf.d/00-keyboard.conf
info "Set hostname..."
echo "$HOSTNAME" > $TMPDIR/root/etc/hostname
info "Fix update-uboot for pinebook-pro-rk3399"
# Fixed in arm-image-installer => 3.0
if [ ! -f "$TMPDIR/root/usr/share/arm-image-installer/boards.d/pinebook-pro-rk3399" ]; then
ln -s ../socs.d/Rockchips-ARMv8 $TMPDIR/root/usr/share/arm-image-installer/boards.d/pinebook-pro-rk3399
fi
# Extract firmware dptx.bin
xz -d $TMPDIR/root/usr/lib/firmware/rockchip/dptx.bin.xz 1> /dev/null 2>&1
info "Setting up users..."
#setup users
echo "$USER" > $TMPDIR/user
echo "$PASSWORD" > $TMPDIR/password
echo "$ROOTPASSWORD" > $TMPDIR/rootpassword
info "Setting password for root ..."
$NSPAWN $TMPDIR/root awk -i inplace -F: "BEGIN {OFS=FS;} \$1 == \"root\" {\$2=\"$(openssl passwd -1 $(cat $TMPDIR/rootpassword))\"} 1" /etc/shadow 1> /dev/null 2>&1
info "Adding user..."
$NSPAWN $TMPDIR/root useradd -m -G wheel -p $(openssl passwd -1 $(cat $TMPDIR/password)) -s /bin/bash $(cat $TMPDIR/user) 1> /dev/null 2>&1
$NSPAWN $TMPDIR/root usermod -aG $USERGROUPS $(cat $TMPDIR/user) 1> /dev/null 2>&1
$NSPAWN $TMPDIR/root chfn -f "$FULLNAME" $(cat $TMPDIR/user) 1> /dev/null 2>&1
# Remove temp files on host
rm -rf $TMPDIR/user $TMPDIR/password $TMPDIR/rootpassword
msg "$DEVICE $EDITION install complete"
}
prepare_card () {
msg "Getting $SDCARD ready for $DEVICE..."
# umount and clear SD card
umount ${SDCARD}* 1> /dev/null 2>&1
umount ${SDCARD}* 1> /dev/null 2>&1
umount ${SDCARD}* 1> /dev/null 2>&1
umount ${SDCARD}* 1> /dev/null 2>&1
umount ${SDCARD}* 1> /dev/null 2>&1
umount ${SDCARD}* 1> /dev/null 2>&1
wipefs -a ${SDCARD} 1> /dev/null 2>&1
echo -e "label:gpt" | sfdisk ${SDCARD} 1> /dev/null 2>&1
info "Create partitions..."
#Clear first 32mb
dd if=/dev/zero of=${SDCARD} bs=1M count=32 1> /dev/null 2>&1
info "Partition $DEV_NAME"
info "Partition with boot and root"
echo -e "label:gpt\nunit:sectors\nfirst-lba:32768" | sfdisk ${SDCARD} 1> /dev/null 2>&1
echo -e "n\n1\n32768\n+1G\nn\n2\n\n\nx\nA\n1\nr\nw" | fdisk ${SDCARD} 1> /dev/null 2>&1
info "List partitions..."
partprobe -s ${SDCARD}
fdisk -l ${SDCARD} 1> /dev/null 2>&1
}
format_card () {
info "Format partitions on $DEV_NAME"
if [[ "$DISKLAYOUT" = "ext4" ]]; then
mkfs.ext4 -F -O ^metadata_csum,^64bit "${SDCARD}${SDDEV}1" -L "${DEV_NAME}-boot" 1> /dev/null 2>&1
mkfs.ext4 -F -O ^metadata_csum,^64bit "${SDCARD}${SDDEV}2" -L "${DEV_NAME}-root" 1> /dev/null 2>&1
sleep 1
mkdir -p $TMPDIR/root
mount ${SDCARD}${SDDEV}2 $TMPDIR/root || exit
sleep 1
mkdir -p $TMPDIR/root/boot
mount ${SDCARD}${SDDEV}1 $TMPDIR/root/boot || exit
sleep 1
else
# DISKLAYOUT = btrfs
mkfs.ext4 -F -O ^metadata_csum,^64bit "${SDCARD}${SDDEV}1" -L "${DEV_NAME}-boot" 1> /dev/null 2>&1
mkfs.btrfs -f "${SDCARD}${SDDEV}2" -L "<FS_TREE>" 1> /dev/null 2>&1
mkdir -p $TMPDIR/root
mount ${SDCARD}${SDDEV}2 $TMPDIR/root || exit
sleep 1
info "Create btrfs subvolumes..."
btrfs subvolume create $TMPDIR/root/root 1> /dev/null 2>&1
btrfs subvolume create $TMPDIR/root/home 1> /dev/null 2>&1
umount $TMPDIR/root || exit
sleep 1
info "Mount all partitions..."
mount -t btrfs -o subvol=root,compress=zstd:1,noatime ${SDCARD}${SDDEV}2 $TMPDIR/root || exit
sleep 1
mkdir -p $TMPDIR/root/home
mount -t btrfs -o subvol=home,compress=zstd:1,noatime ${SDCARD}${SDDEV}2 $TMPDIR/root/home || exit
sleep 1
mkdir -p $TMPDIR/root/boot
mount ${SDCARD}${SDDEV}1 $TMPDIR/root/boot || exit
sleep 1
fi
}
cleanup () {
msg "Writing bootloader and cleaning up after install..."
# Flash bootloader
dd if=$TMPDIR/root/boot/idbloader.img of=${SDCARD} seek=64 conv=notrunc,fsync 1> /dev/null 2>&1
dd if=$TMPDIR/root/boot/u-boot.itb of=${SDCARD} seek=16384 conv=notrunc,fsync 1> /dev/null 2>&1
info "Apply workaround for poor key import UI in PackageKit"
$NSPAWN $TMPDIR/root rm -f /var/lib/rpm/__db* 1> /dev/null 2>&1
$NSPAWN $TMPDIR/root rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$(rpm --eval '%{fedora}')-$arch 1> /dev/null 2>&1
# "Packages within this ARM disk image"
$NSPAWN $TMPDIR/root rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn 1> /dev/null 2>&1
# Note that running rpm recreates the rpm db files which aren't needed or wanted
$NSPAWN $TMPDIR/root rm -f /var/lib/rpm/__db* 1> /dev/null 2>&1
info "Remove random seed, the new install should make it's own"
$NSPAWN $TMPDIR/root rm -f /var/lib/systemd/random-seed 1> /dev/null 2>&1
info "Disabling tmpfs for /tmp."
$NSPAWN $TMPDIR/root systemctl mask tmp.mount 1> /dev/null 2>&1
info "Reset machine-id"
$NSPAWN $TMPDIR/root rm -f /etc/machine-id 1> /dev/null 2>&1
touch /etc/machine-id 1> /dev/null 2>&1
#clean up
umount $TMPDIR/root/home 1> /dev/null 2>&1
umount $TMPDIR/root/boot
umount $TMPDIR/root
partprobe $SDCARD 1> /dev/null 2>&1
rm -rf $TMPDIR
msg "Not removing installation media $MEDIADIR"
}
if [ ! -z "$EDITION" ]; then
USER=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--inputbox "Enter the username you want:
(usernames most be all lowercase)" 8 50 \
3>&1 1>&2 2>&3 3>&-)
if [[ "$USER" =~ [A-Z] ]] || [[ "$USER" == *['!'@#\$%^\&*()_+]* ]]; then
clear
msg "Configuration aborted! Username contained invalid characters."
exit 1
fi
else
clear
exit 1
fi
if [ ! -z "$USER" ]
then
FULLNAME=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--inputbox "Enter desired Full Name for $USER:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$FULLNAME" ]; then
PASSWORD=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--insecure --passwordbox "Enter new Password for $USER:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$PASSWORD" ]; then
CONFIRMPASSWORD=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--insecure --passwordbox "Confirm new Password for $USER:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [[ "$PASSWORD" != "$CONFIRMPASSWORD" ]]; then
clear
msg "User passwords do not match! Please restart the installer and try again."
exit 1
fi
if [ ! -z "$CONFIRMPASSWORD" ]; then
ROOTPASSWORD=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--insecure --passwordbox "Enter new Root Password:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$ROOTPASSWORD" ]; then
CONFIRMROOTPASSWORD=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--insecure --passwordbox "Confirm new Root Password:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [[ "$ROOTPASSWORD" != "$CONFIRMROOTPASSWORD" ]]; then
clear
msg "Root passwords do not match! Please restart the installer and try again."
exit 1
fi
if [ ! -z "$CONFIRMROOTPASSWORD" ]
then
# simple command to put the results of lsblk (just the names of the devices) into an array and make that array populate the options
let i=0
W=()
while read -r line; do
let i=$i+1
W+=($line "")
done < <( lsblk -dn -o NAME )
SDCARD=$(dialog --title "Fedora Pinebook Pro Installer" \
--menu "Choose your SDCard/eMMC/USB - Be sure the correct drive is selected!
WARNING! This WILL destroy the data on it!" 20 50 10 \
"${W[@]}" 3>&2 2>&1 1>&3)
# add /dev/ to the selected option above
DEV_NAME=$SDCARD
SDCARD=/dev/$SDCARD
SDTYP=${SDCARD:5:2}
else
clear
exit 1
fi
if [[ "$SDTYP" = "sd" || "$SDTYP" = "vd" ]]; then
SDDEV=""
elif [[ "$SDTYP" = "mm" || "$SDTYP" = "lo" || "$SDTYP" = "nv" ]]; then
SDDEV="p"
else
clear
exit 1
fi
if [ ! -z "$SDCARD" ]; then
DISKLAYOUT=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose a disk layout:" 20 75 10 \
"btrfs" "btrfs on root and ext4 boot" \
"ext4" "ext4 on root and boot" \
3>&1 1>&2 2>&3 3>&-)
else
clear
exit 1
fi
if [ ! -z "$DISKLAYOUT" ]; then
KERNELVER=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose Kernel:" 20 75 10 \
"kernel-pbp" "Vanilla with fedora config patched for pbp" \
"linux-majaro" "Manjaro kernel repacked in rpm (no SELINUX)" \
3>&1 1>&2 2>&3 3>&-)
else
clear
exit 1
fi
if [ ! -z "$KERNELVER" ]; then
DNFUPGRADE=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Upgrade during install?" 20 75 10 \
"yes" "Upgrade all to current version" \
"no" "Install version from image" \
3>&1 1>&2 2>&3 3>&-)
else
clear
exit 1
fi
if [ ! -z "$DNFUPGRADE" ]; then
let i=0
W=()
while read -r line; do
let i=$i+1
W+=($line "")
done < <( timedatectl list-timezones )
TIMEZONE=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose your timezone!" 20 50 15 \
"${W[@]}" 3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$TIMEZONE" ]; then
let i=0
W=()
while read -r line; do
let i=$i+1
W+=($line "")
done < <( localectl list-locales )
LOCALE=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose your locale!" 20 50 15 \
"${W[@]}" 3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$LOCALE" ]; then
let i=0
W=()
while read -r line; do
let i=$i+1
W+=($line "")
done < <( localectl list-keymaps )
CLIKEYMAP=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose your TTY keyboard layout:" 20 50 15 \
"${W[@]}" 3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$CLIKEYMAP" ]; then
let i=0
W=()
while read -r line; do
let i=$i+1
W+=($line "")
done < <( localectl list-x11-keymap-layouts )
X11KEYMAP=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--menu "Choose your X11 keyboard layout:" 20 50 15 \
"${W[@]}" 3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$CLIKEYMAP" ]; then
HOSTNAME=$(dialog --clear --title "Fedora Pinebook Pro Installer" \
--inputbox "Enter desired hostname (fqdn) for this system:" 8 50 \
3>&1 1>&2 2>&3 3>&- \
)
else
clear
exit 1
fi
if [ ! -z "$HOSTNAME" ]; then
dialog --clear --title "Fedora Pinebook Pro Installer" \
--yesno "Is the below information correct:
Device = $DEVICE
Edition = $EDITION
Username = $USER
Additional usergroups = $USERGROUPS
Password for $USER = (password hidden)
Password for root = (password hidden)
SDCard/eMMC/USB = $SDCARD
Disklayout = $DISKLAYOUT
Kernel = $KERNELVER
Upgrade = $DNFUPGRADE
Timezone = $TIMEZONE
Locale = $LOCALE
Keyboard layout = $CLIKEYMAP
Hostname = $HOSTNAME" 20 70 \
3>&1 1>&2 2>&3 3>&-
else
clear
exit 1
fi
response=$?
case $response in
0) clear; msg "Installation started....";;
1) clear; msg "Installation aborted...."; exit 1;;
255) clear; msg "Installation aborted..."; exit 1;;
esac
if [ ! -f "$TMPDIR" ]; then
rm -rf $TMPDIR
fi
mkdir -p $MEDIADIR
mkdir -p $TMPDIR
# Commands
timer_start=$(get_timer)
prepare_media
prepare_card
format_card
install_fedora
upgrade_fedora
configure_fedora
cleanup
show_elapsed_time "${FUNCNAME}" "${timer_start}"
sync