-
Notifications
You must be signed in to change notification settings - Fork 60
/
chrx-install-chroot
744 lines (646 loc) · 21.3 KB
/
chrx-install-chroot
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
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
#!/bin/bash
#
# chrx-install-chroot
#
# This portion of the installation process is run in a chroot.
#
echo_title() { echo -e "\n${ANSI_GRN}${*}${ANSI_RST}"; }
echo_title_yel() { echo -e "\n${ANSI_YEL}${*}${ANSI_RST}"; }
echo_title_red() { echo -e "\n${ANSI_RED}${*}${ANSI_RST}"; }
debug_shell()
{
echo_title_red "debug shell ($@), exit to continue."
/bin/bash -i
}
apt_get_update()
{
echo_title "Reloading repository manifests."
apt-get -y -qq update
#debug_shell apt_get_update
APT_DB_NEEDS_UPDATE=
}
apt_get_update_if_needed()
{
[ "${APT_DB_NEEDS_UPDATE}" ] && apt_get_update
}
ubuntu_update_core_image()
{
echo_title "Upgrading Ubuntu core image."
apt_get_update_if_needed
apt-get -y ${VERBOSITY_APTGET} dist-upgrade
apt_get_install ubuntu-minimal
apt_get_install software-properties-common
}
install_curl()
{
apt_get_update_if_needed
apt_get_install curl
}
install_utilities()
{
apt_get_update_if_needed
apt_get_install zram-config grub-pc
}
apt_get_install()
{
apt-get -y ${VERBOSITY_APTGET} install $*
}
install_additional_packages()
{
for pkg in ${CHRX_ADD_PKGS}; do
echo_title "Installing additional package \"${pkg}\"."
case $pkg in
kodi) install_kodi ;;
admin-misc) apt_get_install vim tmux ssh rsync ;;
dev-misc) apt_get_install arduino geany geany-plugins ruby ;;
minecraft) install_minecraft ;;
steam) install_steam ;;
simplescreenrecorder) install_simplescreenrecorder ;;
chrome) install_google_chrome_from_deb ;;
_hdr) install_set_hdr ;;
*) apt_get_install $pkg ;;
esac
done
}
install_simplescreenrecorder()
{
add-apt-repository -y ppa:maarten-baert/simplescreenrecorder
apt_get_update
apt_get_install simplescreenrecorder
}
install_steam()
{
curl -o /tmp/steam_latest.deb \
http://repo.steampowered.com/steam/archive/precise/steam_latest.deb
dpkg -i /tmp/steam_latest.deb
## steam launcher requires python-apt in xenial
## python-apt does not exist in vivid
apt-get -y -f install
}
install_minecraft()
{
apt_get_install default-jre
curl -o /usr/local/bin/Minecraft.jar \
https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar
curl -o /usr/share/pixmaps/minecraft.png https://chrx.org/minecraft.png
mkdir -p /usr/local/share/applications
cat > /usr/local/share/applications/minecraft.desktop <<-EOF
[Desktop Entry]
Type=Application
Name=Minecraft
Comment=Minecraft
Exec=java -jar /usr/local/bin/Minecraft.jar
Icon=/usr/share/pixmaps/minecraft.png
Categories=Game;
EOF
}
install_kodi()
{
apt_get_install python-software-properties pkg-config
apt_get_install software-properties-common
add-apt-repository -y ppa:team-xbmc/ppa
apt_get_update
apt_get_install kodi
}
install_google_chrome_from_deb()
{
curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb
apt-get -f -y install
rm -f google-chrome-stable_current_amd64.deb
}
install_set_hdr()
{
apt_get_install vim tmux ssh rsync
apt_get_install arduino geany geany-plugins ruby
install_minecraft
install_steam
install_google_chrome_from_deb
}
fedora_install_additional_packages()
{
for pkg in ${CHRX_ADD_PKGS}; do
echo_title "Installing additional package \"${pkg}\"."
case $pkg in
admin-misc)
dnf ${VERBOSITY_DNF} -y install vim tmux rsync openssh
;;
dev-misc)
dnf ${VERBOSITY_DNF} -y install arduino geany geany-plugins-addons ruby ;;
kodi)
fedora_install_rpmfusion;
dnf ${VERBOSITY_DNF} -y install kodi
;;
minecraft)
fedora_install_minecraft
;;
steam)
fedora_install_rpmfusion
dnf ${VERBOSITY_DNF} -y install steam
;;
simplescreenrecorder)
fedora_install_rpmfusion
dnf ${VERBOSITY_DNF} -y install simplescreenrecorder
;;
chrome)
fedora_install_google_chrome
;;
_hdr)
fedora_install_set_hdr
;;
*)
dnf ${VERBOSITY_DNF} -y install $pkg ;;
esac
done
}
fedora_install_minecraft()
{
dnf ${VERBOSITY_DNF} -y install java
curl -o /usr/local/bin/Minecraft.jar \
https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar
curl -o /usr/share/pixmaps/minecraft.png https://chrx.org/minecraft.png
mkdir -p /usr/local/share/applications
cat > /usr/local/share/applications/minecraft.desktop <<-EOF
[Desktop Entry]
Type=Application
Name=Minecraft
Comment=Minecraft
Exec=java -jar /usr/local/bin/Minecraft.jar
Icon=/usr/share/pixmaps/minecraft.png
Categories=Game;
EOF
}
fedora_install_set_hdr()
{
fedora_install_rpmfusion
dnf ${VERBOSITY_DNF} -y install vim tmux rsync openssh
dnf ${VERBOSITY_DNF} -y install arduino geany geany-plugins-addons ruby
fedora_install_minecraft
dnf ${VERBOSITY_DNF} -y install steam
fedora_install_google_chrome
}
ubuntu_add_repos()
{
echo_title "Adding Ubuntu software respositories."
add-apt-repository -y main
add-apt-repository -y universe
add-apt-repository -y restricted
add-apt-repository -y multiverse
APT_DB_NEEDS_UPDATE=1
}
galliumos_add_repos()
{
echo_title "Adding GalliumOS software respositories."
curl -O ${VERBOSITY_CURL} http://apt.galliumos.org/galliumos.gpg
apt-key add galliumos.gpg
add-apt-repository -y 'deb http://apt.galliumos.org/ vivid-galliumos main'
APT_DB_NEEDS_UPDATE=1
}
galliumos_install_base()
{
apt_get_update_if_needed
echo_title "Installing GalliumOS base pkgs."
apt_get_install galliumos-base
}
galliumos_install_hwspecific()
{
echo_title "Installing GalliumOS hardware compatibility pkgs."
apt_get_update_if_needed
## install proper hwspec pkgs
case "$CHRX_HWCPUF" in
"Intel Sandy Bridge") hwspec_pkgs="galliumos-sandy" ;;
"Intel Ivy Bridge") hwspec_pkgs="galliumos-sandy" ;;
"Intel Haswell") hwspec_pkgs="galliumos-haswell" ;;
"Intel Broadwell") hwspec_pkgs="galliumos-broadwell" ;;
"Intel Bay Trail") hwspec_pkgs="galliumos-baytrail" ;;
"Intel Braswell") hwspec_pkgs="galliumos-braswell" ;;
"Intel Skylake") hwspec_pkgs="galliumos-skylake" ;;
"Intel Apollo Lake") hwspec_pkgs="galliumos-apollolake" ;;
"Intel Kaby Lake") hwspec_pkgs="galliumos-kabylake" ;;
"Intel Gemini Lake") hwspec_pkgs="galliumos-apollolake" ;;
"Intel Amber Lake") hwspec_pkgs="galliumos-kabylake" ;;
esac
case "$CHRX_HWID" in
"SAMUS") hwspec_pkgs="galliumos-samus" ;;
"LINK") hwspec_pkgs+=" galliumos-hidpi" ;;
"CHELL") hwspec_pkgs+=" galliumos-hidpi" ;;
esac
## TODO: add galliumos-cbox instead of galliumos-laptop for Chromeboxes
apt_get_install galliumos-laptop ${hwspec_pkgs}
}
install_distenv()
{
apt_get_update_if_needed
echo_title "Installing \"${CHRX_OS_DISTENV}\"."
apt_get_install "${CHRX_OS_DISTENV}"
}
fedora_install_distenv()
{
case "${CHRX_OS_DISTENV}" in
fedora-desktop|fedora-workstation)
CHRX_OS_DISTENV="Fedora Workstation"
;;
fedora-kde)
CHRX_OS_DISTENV="KDE Plasma Workspaces"
;;
fedora-xfce)
CHRX_OS_DISTENV="Xfce Desktop"
;;
fedora-lxde)
CHRX_OS_DISTENV="LXDE Desktop"
;;
fedora-lxqt)
CHRX_OS_DISTENV="LXQt Desktop"
;;
fedora-cinnamon)
CHRX_OS_DISTENV="Cinnamon Desktop"
;;
fedora-mate)
CHRX_OS_DISTENV="MATE Desktop"
;;
fedora-sugar)
CHRX_OS_DISTENV="Sugar Desktop Environment"
;;
fedora-minimal)
CHRX_OS_DISTENV="Minimal Install"
dnf ${VERBOSITY_DNF} -y install wpa_supplicant
;;
*)
CHRX_OS_DISTENV="Basic Desktop"
;;
esac
echo_title "Installing \"${CHRX_OS_DISTENV}\"."
dnf ${VERBOSITY_DNF} -y --allowerasing group install "${CHRX_OS_DISTENV}"
}
chrome_add_repos()
{
echo_title "Adding Google Chrome software respositories."
curl -O ${VERBOSITY_CURL} https://dl-ssl.google.com/linux/linux_signing_key.pub
apt-key add linux_signing_key.pub
add-apt-repository -y "deb http://dl.google.com/linux/chrome/deb/ stable main"
APT_DB_NEEDS_UPDATE=1
}
add_first_user()
{
echo_title "Creating user \"${CHRX_USERNAME}\"."
useradd -m ${CHRX_USERNAME} -s /bin/bash
echo ${CHRX_USERNAME}:${CHRX_USERNAME} | chpasswd
local _groups
case "${CHRX_OS_DISTRO}" in
fedora) _groups="adm wheel cdrom" ;;
*) _groups="adm sudo cdrom dip plugdev lpadmin" ;; #sambashare
esac
echo_title "Adding user \"${CHRX_USERNAME}\" to groups \"$_groups\"."
## add individually in case any groups do not exist (fixes #30)
for group in $_groups; do
usermod -a -G ${group} ${CHRX_USERNAME}
done
}
configure_grub()
{
## set resume parm to partition 5, only when installing to rootdev
## TODO: would this overwrite ChromeOS hibernate image?
CHRX_RESUME_PARTITION="noresume"
#if [ "$(rootdev -d -s)" = "$CHRX_TARGET_DISK" ]; then
# case "${CHRX_TARGET_DISK}" in
# "/dev/sda") CHRX_RESUME_PARTITION="resume=/dev/sda5" ;;
# "/dev/mmcblk0") CHRX_RESUME_PARTITION="resume=/dev/mmcblk0p5" ;;
# esac
#fi
## comment old settings
sed -i~ 's/^\(GRUB_HIDDEN_TIMEOUT\)/#\1/g' /etc/default/grub
sed -i~ 's/^\(GRUB_TIMEOUT\)/#\1/g' /etc/default/grub
sed -i~ 's/^\(GRUB_CMDLINE_LINUX\)/#\1/g' /etc/default/grub
## add our settings
cat >> /etc/default/grub <<EO_GRUB
## boot settings
##
## GRUB_TIMEOUT delay before boot (ESC for menu), in seconds
## GRUB_TIMEOUT_STYLE UI for delay (menu|countdown|hidden)
GRUB_TIMEOUT=10
GRUB_TIMEOUT_STYLE=menu
GRUB_GFXMODE=1920x1080,1680x1050,1600x900,1366x768,1280x850,1024x768,auto
GRUB_TERMINAL_OUTPUT=gfxterm
## kernel parameters
##
## GRUB_CMDLINE_LINUX_DEFAULT sets parms for normal boot
## GRUB_CMDLINE_LINUX sets parms for normal and recovery boot
##
## quiet suppress most messages
## splash boot with splash screen
## boot=local (redundant?)
## acpi_osi=Linux add Linux to list of supported OS interfaces
## acpi_backlight=vendor prefer vendor backlight driver
## add_efi_memmap include EFI extensions to E820 BIOS map
## intel_pstate=enable enable CPI power state management, cpupower(8)
## i915.modeset=1 setting for Intel 915 GPU/HD Audio chip
## tpm_tis.force=1 ignore ACPI TPM interrupts, poll instead
## tpm_tis.interrupts=0 skip TPM interrupt probing (redundant with prev)
## nmi_watchdog=panic,lapic panic when NMI watchdog expires or local APIC
## elevator=noop do not reorder disk IO to minimize head seeks
## resume=/dev/sda5 save hibernation state to /dev/sda5
## noresume no resume partition (for hibernate)
## noswap no swap partition
##
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash boot=local acpi_osi=Linux acpi_backlight=vendor add_efi_memmap intel_pstate=enable i915.modeset=1 tpm_tis.force=1 tpm_tis.interrupts=0 nmi_watchdog=panic,lapic elevator=noop ${CHRX_RESUME_PARTITION}"
EO_GRUB
}
set_timezone()
{
echo_title "Setting timezone to \"${CHRX_TZ}\"."
dpkg-reconfigure tzdata
}
fedora_set_timezone()
{
echo_title "Setting timezone to \"${CHRX_TZ}\"."
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/${CHRX_TZ} /etc/localtime
}
install_language_support()
{
echo_title "Installing language support."
apt_get_install language-pack-en language-pack-gnome-en firefox-locale-en wbritish hunspell-en-ca
}
set_locale()
{
echo_title "Setting locale to \"${CHRX_LOCALE}\"."
update-locale LANG=${CHRX_LOCALE} LC_MESSAGES=${CHRX_LOCALE}
}
fedora_set_locale()
{
CHRX_LOCALE=${CHRX_LOCALE/UTF/utf}
keymap=${CHRX_LOCALE:3:2}
keymap=${keymap,,}
echo_title "Setting locale to \"${CHRX_LOCALE}\"."
echo "LANG=${CHRX_LOCALE}" > /etc/locale.conf
echo_title "Setting keyboard map to \"${keymap}\"."
echo "KEYMAP=${keymap}" > /etc/vconsole.conf
cat << EOF > /etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "${keymap}"
EndSection
EOF
}
install_google_chrome()
{
[ ! -x /usr/bin/X ] && return ## only if we have X
apt_get_update_if_needed
echo_title "Installing Google Chrome."
apt_get_install google-chrome-stable
}
fedora_install_google_chrome()
{
[ ! -x /usr/bin/X ] && return ## only if we have X
echo_title "Installing Google Chrome."
dnf ${VERBOSITY_DNF} -y install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
}
fedora_install_rpmfusion()
{
echo_title "Installing RPM Fusion software repository."
dnf ${VERBOSITY_DNF} -y install \
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
}
fedora_install_codecs()
{
[ ! -x /usr/bin/X ] && return ## only if we have X
fedora_install_rpmfusion
echo_title "Installing non-free codecs codecs."
dnf ${VERBOSITY_DNF} -y install gstreamer gstreamer-plugins-base gstreamer-plugins-good \
gstreamer-plugins-good-extras gstreamer-plugins-bad gstreamer-plugins-bad-free gstreamer-plugins-bad-free-extras \
gstreamer-plugins-bad-nonfree gstreamer-plugins-ugly gstreamer-ffmpeg
dnf ${VERBOSITY_DNF} -y install gstreamer1 gstreamer1-plugins-base gstreamer1-plugins-base-tools gstreamer1-plugins-good gstreamer1-plugins-good-extras gstreamer1-plugins-bad-free gstreamer1-plugins-bad-free-extras gstreamer1-plugins-bad-freeworld gstreamer1-plugins-ugly gstreamer1-libav
dnf ${VERBOSITY_DNF} -y install faad2 faac libdca compat-libstdc++-33 compat-libstdc++-296 xine-lib-extras-freeworld
}
install_desktop_support()
{
[ ! -x /usr/bin/X ] && return ## only if we have X
[ ! "${CHRX_CUSTOMIZATION_ENABLED}" ] && return
echo_title "Installing desktop compatibility pkgs."
apt_get_install xbindkeys xdotool xbacklight xvkbd
}
fedora_install_desktop_support()
{
[ ! -x /usr/bin/X ] && return ## only if we have X
echo_title "Installing desktop compatibility pkgs."
dnf ${VERBOSITY_DNF} -y install xbindkeys xdotool xbacklight xvkbd
# fix missing link to display-manager
if [ -e /usr/lib/systemd/system/gdm.service ]; then
ln -s /usr/lib/systemd/system/gdm.service /etc/systemd/system/display-manager.service
elif [ -e /usr/lib/systemd/system/lightdm.service ]; then
ln -s /usr/lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service
elif [ -e /usr/lib/systemd/system/sddm.service ]; then
ln -s /usr/lib/systemd/system/sddm.service /etc/systemd/system/display-manager.service
fi
}
install_kernel()
{
echo_title "Installing Linux kernel and boot environment."
apt_get_install linux-image-generic
apt_get_install linux-headers-generic
}
fedora_install_kernel()
{
echo "add_drivers+=\" mmc_core mmc_block sdhci sdhci_acpi \"" > /etc/dracut.conf.d/chrx.conf
echo_title "Installing Linux kernel and boot environment."
# Remove anything installed outside the chroot in case the main install
# has included these accidentally
dnf ${VERBOSITY_DNF} -y remove kernel kernel-modules kernel-core linux-firmware
# install the release kernel
dnf ${VERBOSITY_DNF} -y --disablerepo "updates" install kernel kernel-modules kernel-core linux-firmware
#and then update to the latest
dnf ${VERBOSITY_DNF} -y update
}
install_kernel_newer_than_min()
{
## Current Ubuntu LTS is 14.04.3, which delivers kernel version 3.14.1.
## We need a minumum kernel version of 3.17 for important cyapa trackpad
## patches, so we will update the kernel to the latest 3.17 if necessary.
## TODO: keep these updated, though we do check before installing!
NEW_KERNEL_BASE="http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic"
NEW_KERNEL_REV="3.17.1-031701_3.17.1-031701.201410150735"
NEW_KERNEL_GREV="3.17.1-031701-generic_3.17.1-031701.201410150735"
NEW_KV_MAJ=3
NEW_KV_MIN=17
NEW_KV_PAT=1
## install newest-released kernel, iff installed kernel is older
KV=`dpkg -s linux-image-generic|grep "^Version:"|cut -d\ -f2|cut -d\. -f1-3`
KV_MAJ=`echo ${KV} | cut -d\. -f1`
KV_MIN=`echo ${KV} | cut -d\. -f2`
KV_PAT=`echo ${KV} | cut -d\. -f3`
echo_title "Installed kernel is version ${KV_MAJ}.${KV_MIN}.${KV_PAT}"
new_is_newer=""
if [ "${NEW_KV_MAJ}" -gt "${KV_MAJ}" ]; then
new_is_newer="yes"
elif [ "${NEW_KV_MAJ}" -eq "${KV_MAJ}" ]; then
if [ "${NEW_KV_MIN}" -gt "${KV_MIN}" ]; then
new_is_newer="yes"
elif [ "${NEW_KV_MIN}" -eq "${KV_MIN}" ]; then
if [ "${NEW_KV_PAT}" -gt "${KV_PAT}" ]; then
new_is_newer="yes"
fi
fi
fi
if [ "${new_is_newer}" ]; then
echo "Newer kernel available (${NEW_KERNEL_REV} > ${KV})"
echo_title "Installing updated Linux kernel (version ${NEW_KERNEL_REV})"
rm -f linux-*.deb
curl -O ${VERBOSITY_CURL} ${NEW_KERNEL_BASE}/linux-image-${NEW_KERNEL_GREV}_amd64.deb
curl -O ${VERBOSITY_CURL} ${NEW_KERNEL_BASE}/linux-headers-${NEW_KERNEL_GREV}_amd64.deb
curl -O ${VERBOSITY_CURL} ${NEW_KERNEL_BASE}/linux-headers-${NEW_KERNEL_REV}_all.deb
dpkg -i linux-*.deb
rm -f linux-*.deb
else
echo "Installed kernel is newest-known (${KV} >= ${NEW_KERNEL_REV})"
fi
}
galliumos_update_core_image()
{
apt_get_update
echo_title "Upgrading GalliumOS core image."
## FIXME: need --force-yes until GalliumOS pkg versioning is fixed
apt-get -y --force-yes ${VERBOSITY_APTGET} dist-upgrade
APT_DB_NEEDS_UPDATE=1
}
write_default_fstab()
{
## FIXME be smarter here
if [ -z "${CHRX_ROOT_PARTITION}" ]; then
echo_title_red "Unable to configure default fstab, CHRX_ROOT_PARTITION is unset!"
return
fi
echo "${CHRX_ROOT_PARTITION} / ext4 defaults,discard,relatime 1 1" >> /etc/fstab
}
create_fakebins()
{
## create fake bins to stymie ubuntu's poor autostart hygiene
local _bins="initctl invoke-rc.d restart start stop start-stop-daemon service"
rm -rf /tmp/fakebin
mkdir -p /tmp/fakebin
for bin in $_bins; do
ln -s /bin/true /tmp/fakebin/${bin}
done
export PATH=/tmp/fakebin:$PATH
}
install_grub()
{
#apt_get_install grub-pc
## GRUB: modify boot settings
## unfortunately, we have to do this in the chroot.
if [ "${CHRX_CONFIGURE_GRUB_ENABLED}" ]; then
configure_grub
else
echo_title_yel "(skipping chrx grub config)"
fi
grub-mkconfig -o /boot/grub/grub.cfg
grub-install ${CHRX_TARGET_DISK} --force
#echo -e "\n${ANSI_GRN}Purging unwanted pkgs.${ANSI_RST}"
#apt-get -y ${VERBOSITY_APTGET} purge openjade openjade1.3 jade tex-common sgml-base
#apt-get -y ${VERBOSITY_APTGET} autoremove
}
fedora_install_grub2()
{
# fedora expects anaconda to set the defaults file
cat << EOF > /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rhgb quiet intel_pstate=enable i915.modeset=1 tpm_tis.force=1 nmi_watchdog=panic,lapic elevator=noop noswap"
GRUB_DISABLE_RECOVERY="true"
GRUB_DISABLE_LINUX_UUID="true"
EOF
dnf ${VERBOSITY_DNF} -y install grub2
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install ${CHRX_TARGET_DISK} --force
}
fedora_set_selinux_autolabel()
{
if [ -z "${CHRX_CUSTOMIZATION_ENABLED}" ]; then
touch /.autorelabel
fi
}
## begin
#echo debug ; bash
case "${CHRX_OS_DISTRO}" in
*ubuntu)
export DEBIAN_FRONTEND=noninteractive
echo ${CHRX_TZ} > /etc/timezone
create_fakebins
apt_get_update
ubuntu_update_core_image
install_curl
ubuntu_add_repos
install_utilities
#ubuntu_install
install_distenv
set_timezone
#if [ "${CHRX_OS_DISTENV}" != "ubuntu-minimal" ]; then
# install_distenv
#fi
install_language_support ## TODO: ubuntu-only? req for set_locale?
set_locale
install_desktop_support ## TODO: ubuntu-only?
#chrome_add_repos
#install_google_chrome
install_kernel
install_kernel_newer_than_min
## EO "ubuntu-only?"
install_additional_packages
write_default_fstab
apt-get -y ${VERBOSITY_APTGET} autoremove
apt-get -y ${VERBOSITY_APTGET} clean
dpkg-query -W --showformat='${Package} ${Version}\n' > ${CHRX_CACHE_DIR}/apt-list-installed 2>&1
install_grub
;;
galliumos)
export DEBIAN_FRONTEND=noninteractive
echo ${CHRX_TZ} > /etc/timezone
create_fakebins
apt_get_update
apt_get_install software-properties-common
install_curl
install_utilities
set_timezone
set_locale
#galliumos_add_repos ## not needed, core image is preconfigured
galliumos_update_core_image
galliumos_install_hwspecific
install_additional_packages
write_default_fstab
apt-get -y ${VERBOSITY_APTGET} autoremove
apt-get -y ${VERBOSITY_APTGET} clean
dpkg-query -W --showformat='${Package} ${Version}\n' > ${CHRX_CACHE_DIR}/apt-list-installed 2>&1
install_grub
;;
# galliumos_apt)
# ubuntu_update_core_image
# install_curl
# ubuntu_add_repos
# install_utilities
# galliumos_add_repos
# galliumos_install_base
# install_distenv
# galliumos_install_hwspecific
# ;;
fedora)
fedora_install_kernel
fedora_install_distenv
fedora_set_timezone
fedora_set_locale
write_default_fstab
fedora_install_grub2
if [ "${CHRX_CUSTOMIZATION_ENABLED}" ]; then
fedora_install_desktop_support
fedora_install_google_chrome
fedora_install_codecs
else
fedora_set_selinux_autolabel
fi
fedora_install_additional_packages
;;
esac
add_first_user