View difference between Paste ID: NtFyycPG and vZBAmFtX
SHOW: | | - or go back to the newest paste.
1
#!/bin/bash
2
# ArChr: a tool to help install Arch Linux on a Chromebook without support for BIOS/legacy boot.
3
# This code is public domain. No warranty of any kind is expressed or implied.
4
5
if [[ $EUID -ne 0 ]]; then
6
    echo "This script must be run as root."
7
    exit 1
8
fi
9
10
# This definitely won't run on a 32-bit system or an ARM.
11
if [[ `uname -m` != "x86_64" ]]; then
12
    echo "This script only works on x86_64."
13
    exit 1
14
fi
15
16
RUNPATH=`readlink -f .`
17
KERNEL=`uname -r`
18
echo "Installing Chrome OS kernel $KERNEL to $RUNPATH..."
19
20
# Make sure the root directory exists. Normally we don't care whether directories exist, but if this isn't here then you're definitely in the wrong place.
21
if [ ! -d root ]; then
22
    echo "Root directory doesn't exist. Are you running this in the directory your Arch install is mounted?"
23
    exit 1
24
fi
25
26
# Look for Chrome OS utilities. cgpt and vbutil_kernel are needed. Other utilities are optional but will be copied if they exist in the same directory.
27
CHROMEBIN_DIR=/usr/bin/old_bins
28
# This was the contents of /usr/bin/old_bins on my system:
29
CHROMEBINS=( cgpt chromeos-tpm-recovery common_minimal.sh crossystem dev_debug_vboot dev_sign_file dumpRSAPublicKey dump_kernel_config enable_dev_usb_boot gbb_utility make_dev_firmware.sh make_dev_ssd.sh resign_firmwarefd.sh set_gbb_flags.sh tpm-nvsize tpm_init_temp_fix tpmc vbutil_firmware vbutil_kernel vbutil_key vbutil_keyblock vbutil_what_keys )
30
if [ ! -x $CHROMEBIN_DIR/cgpt -o ! -x $CHROMEBIN_DIR/vbutil_kernel ]; then
31
    # If old_bins doesn't exist, use which to locate them.
32
    # We search old_bins first because if they ARE in old_bins, the scripts returned by "which" are something different and won't work.
33
    CHROMEBIN_DIR=`dirname $(which cgpt 2>/dev/null) 2>/dev/null`
34
    if [ ! -x "$CHROMEBIN_DIR/cgpt" -o ! -x "$CHROMEBIN_DIR/vbutil_kernel" ]; then
35
        # If they still weren't found, bail.
36
        echo "Chrome OS binaries not found (need cgpt and vbutil_kernel)."
37
        echo "Did you forget to exit your chroot?"
38
        exit 1
39
    fi
40
fi
41
echo "Found chrome binaries in $CHROMEBIN_DIR."
42
43
# We also need dev key files from /usr/share/vboot/devkeys (or /usr/share/chromeboot in the Arch install). I don't know of any other place to find these, so give up if they're not there.
44
CHROMEDEV_DIR=/usr/share/vboot/devkeys
45
CHROME_DEVKEYB=$CHROMEDEV_DIR/kernel.keyblock
46
CHROME_DEVPRIVK=$CHROMEDEV_DIR/kernel_data_key.vbprivk
47
if [ ! -f $CHROME_DEVKEYB -o ! -f $CHROME_DEVPRIVK ]; then
48
    CHROMEDEV_DIR=/usr/share/chromeboot
49
    CHROME_DEVKEYB=$CHROMEDEV_DIR/kernel.keyblock
50
    CHROME_DEVPRIVK=$CHROMEDEV_DIR/kernel_data_key.vbprivk
51
    if [ ! -f $CHROME_DEVKEYB -o ! -f $CHROME_DEVPRIVK ]; then
52
        echo "Couldn't find developer keys. Sorry."
53
        exit 1
54
    fi
55
fi
56
echo "Found developer keys in $CHROMEDEV_DIR."
57
58
# Final sanity check: make sure modules and firmware are present.
59
MODPATH=/lib/modules/$KERNEL
60
if [ ! -d "$MODPATH" ]; then
61
    echo "$MODPATH not found. Sorry."
62
    exit 1
63
fi
64
echo "Found kernel modules in $MODPATH."
65
FWPATH=/lib/firmware
66
if [ ! -d "$FWPATH" ]; then
67
    echo "$FWPATH not found. Sorry."
68
    exit 1
69
fi
70
echo "Found linux firmware in $FWPATH."
71
72
# A standard regex to separate drives from partitions.
73
PARTREGEX='([0-9a-z_/]*[a-z_/])([0-9]+)$'
74
75
# Try to find out which kernel partition we're running. It should be 16MB in size and located right before the / partition.
76
# Check the output of mount first.
77
ROOTDEV=`mount | grep " on / type " | head -1 | cut -d' ' -f1`
78
KERNDEV=""
79
if [[ $ROOTDEV =~ $PARTREGEX ]]; then
80
    KERNDEV=${BASH_REMATCH[1]}$((${BASH_REMATCH[2]} - 1))
81
    [[ `lsblk "$KERNDEV" --output=size 2>/dev/null | tail -1 | tr -d ' '` != "16M" ]] && KERNDEV=""
82
fi
83
# If that didn't do it, try to find the device of / from lsblk.
84
if [[ $KERNDEV == "" && `lsblk --output=name,mountpoint | grep '/$' -B 1 | head -1 | cut -d' ' -f1` =~ $PARTREGEX ]]; then
85
    KERNDEV=/dev/${BASH_REMATCH[1]}$((${BASH_REMATCH[2]} - 1))
86
    [[ `lsblk "$KERNDEV" --output=size 2>/dev/null | tail -1 | tr -d ' '` != "16M" ]] && KERNDEV=""
87
fi
88
# If it wasn't found, ask the user to find the kernel.
89
lsblk
90
if [[ $KERNDEV == "" ]]; then
91
    echo "Kernel partition wasn't auto-detected; you'll have to type it yourself. It should be a 16MB partition in the above list (hint: try to find the partition above the one mounted as /)"
92
    echo "Kernel device path (e.g. /dev/mmcblkXpX): "
93
    read KERNDEV
94
    [[ KERNDEV == "" ]] && exit 0
95
else
96
    echo "Your kernel seems to be in $KERNDEV. If that's not right, type its device path now: "
97
    read KERNDEV2
98
    [[ $KERNDEV2 != "" ]] && KERNDEV=$KERNDEV2
99
fi
100
101
# Ask the user which partition they're installing to.
102
LINUXDEV=`mount | grep " on $RUNPATH type " | head -1 | cut -d' ' -f1`
103
if [[ $LINUXDEV == "" ]]; then
104
    echo "WARNING: Auto-detecting the Arch partition failed. Please make sure you're running this script in the root directory of your Arch install and that you have it mounted properly."
105
    echo "Enter the device path (e.g. /dev/mmcblkXpX) for your Arch install: "
106
    read LINUXDEV
107
    [[ $LINUXDEV == "" ]] && exit 0
108
else
109
    echo "Your Arch install seems to be in $LINUXDEV. If that's not right, type its device path now: "
110
    read LINUXDEV2
111
    if [[ $LINUXDEV2 != "" ]]; then
112
        LINUXDEV=$LINUXDEV2
113
        echo "NOTE: You should be running this script from the root directory of your Arch install. If the device you just saw was your USB or your Chrome OS partition, you're in the wrong place."
114
    fi
115
fi
116
# Apply the same logic as before to check for the kernel partition.
117
LINUXKERNDEV=""
118
[[ $LINUXDEV =~ $PARTREGEX ]] && LINUXKERNDEV=${BASH_REMATCH[1]}$((${BASH_REMATCH[2]} - 1))
119
if [[ $LINUXKERNDEV == "" || "`lsblk "$LINUXKERNDEV" --output=size 2>/dev/null | tail -1 | tr -d ' '`" != "16M" ]]; then
120
    echo "Enter the device path (e.g. /dev/mmcblkXpX) for your Arch kernel: "
121
    read LINUXKERNDEV
122
    [[ $LINUXKERNDEV == "" ]] && exit 0
123
else
124
    echo "Your Arch kernel seems to be in $LINUXKERNDEV. If that's not right, type its device path now: "
125
    read LINUXKERNDEV2
126
    [[ $LINUXKERNDEV2 != "" ]] && LINUXKERNDEV=$LINUXKERNDEV2
127
fi
128
# Make sure we can separate the partition no. from the disk for this device. It's important for chromeboot later.
129
if [[ ! $LINUXKERNDEV =~ $PARTREGEX ]]; then
130
    echo "I don't understand the partition layout on that disk. Sorry."
131
    exit 1
132
fi
133
134
# Look for arch-chroot in the current directory, unless this is running from the Arch install, in which case it's not needed. If the utility isn't found, ask the user where it is.
135
ARCH_CHROOT=usr/bin/arch-chroot
136
if [ "$RUNPATH" != "/" -a ! -x $ARCH_CHROOT ]; then
137
    echo "arch-chroot not found in usr/bin. Please enter its location (e.g. /media/USB/usr/bin): "
138
    read ARCH_CHROOT
139
    ARCH_CHROOT=`readlink -f $ARCH_CHROOT/arch-chroot`
140
    [ ! -x $ARCH_CHROOT ] && exit 0
141
fi
142
143
# Ask if ArChr should be installed on the new partition.
144
SELF=`readlink -f $0`
145
echo "Copy this script to the disk? Enter the full pathname (e.g. \"/root/archr.sh\") or hit Enter to skip: "
146
read SELFINST
147
148
# Done preparing! Confirm with the user that they're ready to start.
149
echo "Ready to install! Press Ctrl+C to cancel or Enter to begin."
150
read
151
152
# Copy self if requested.
153
if [[ $SELFINST != "" ]]; then
154
    SELFINST="./$SELFINST"
155
    mkdir -p "`dirname \"$SELFINST\"`"
156
    cp "$SELF" "$SELFINST"
157
fi
158
159
# Use /proc/cmdline as a basis for the parameters for the new kernel. This helps the new install work better and avoids some kernel panics.
160
# However, remove the dm parameter, replace the root, change the ro mode to rw, and bring back the console (seeing a black screen until the TTY starts up is scary).
161
CMDLINE=`cat /proc/cmdline | sed -e 's/ dm=".*"//;s/ dm[^ ]*=*//g;s|root=[^ ]* |root=$PART_ROOT |;s/ ro / rw /;s/console= //'`
162
163
# Copy the existing kernel partition to the new kernel partition. We'll run chromeboot-update later to finalize it.
164
if [[ $KERNDEV != $LINUXKERNDEV ]]; then
165
    echo "Copying kernel partition..."
166
    dd if="$KERNDEV" of="$LINUXKERNDEV" >/dev/null 2>&1
167
    [ $? -ne 0 ] && exit $?
168
else
169
    echo "Source kernel is the same as destination, skipping copy."
170
fi
171
172
# Make a package for the linux kernel, linux firmware, and the new utilities.
173
echo "Copying modules..."
174
# Set up a build directory under /root.
175
BUILDDIR=root/chromeboot-temp
176
BDLINUX=$BUILDDIR/linux-chromeboot
177
BDFW=$BUILDDIR/linux-chromeboot-firmware
178
BDBOOT=$BUILDDIR/chromeboot
179
rm -rf $BUILDDIR
180
mkdir -p $BDLINUX/src/lib/modules
181
cp -a $MODPATH $BDLINUX/src/lib/modules
182
# Lots of embedded files coming...
183
# BEGIN PKGBUILD FOR linux-chromeboot
184
cat > $BDLINUX/PKGBUILD <<'EOF'
185
pkgname=linux-chromeboot
186
pkgver=<KERNEL>
187
pkgrel=1
188
pkgdesc="The Linux-<KERNEL> kernel and modules for booting on a Chromebook."
189
arch=('x86_64')
190
url="kernel.org"
191
license=('custom')
192
options=('!strip')
193
depends=('coreutils' 'linux-firmware' 'kmod' 'chromeboot')
194
optdepends=('crda: to set the correct wireless channels of your country')
195
provides=("kernel26-chromeboot=${pkgver}" "linux=${pkgver}")
196
conflicts=("kernel26-chromeboot")
197
replaces=("kernel26-chromeboot")
198
199
package() {
200
    install=linux.install
201
    cd "$srcdir"
202
    cp -ar ./* "$pkgdir"
203
}
204
EOF
205
sed -i -e "s/<KERNEL>/$KERNEL/g" $BDLINUX/PKGBUILD
206
# Make an install file to run depmod like the regular kernel. No mkinitcpio (mkinitcpio has also been removed from dependencies) as it's useless with this setup. DO run chromeboot-update, though.
207
cat > $BDLINUX/linux.install <<'EOF'
208
post_install () {
209
    echo ">>> Updating module dependencies. Please wait ..."
210
    depmod <KERNEL>
211
    echo ">>> Running chromeboot-update..."
212
    chromeboot-update
213
}
214
215
post_upgrade () {
216
    echo ">>> Updating module dependencies. Please wait ..."
217
    depmod <KERNEL>
218
    echo ">>> Running chromeboot-update..."
219
    chromeboot-update
220
}
221
EOF
222
sed -i -e "s/<KERNEL>/$KERNEL/g" $BDLINUX/linux.install
223
# END PKGBUILD FOR linux-chromeboot
224
225
# Make a package for the firmware.
226
echo "Copying firmware..."
227
mkdir -p $BDFW/src/usr/lib
228
cp -a $FWPATH $BDFW/src/usr/lib
229
# BEGIN PKGBUILD FOR linux-chromeboot-firmware
230
cat > $BDFW/PKGBUILD <<'EOF'
231
pkgname=linux-chromeboot-firmware
232
pkgver=<KERNEL>
233
pkgrel=1
234
pkgdesc="Firmware files for Chromebook Linux."
235
arch=('x86_64')
236
url="kernel.org"
237
license=('custom')
238
options=('!strip')
239
conflicts=('linux-firmware-git'
240
           'kernel26-firmware'
241
           'ar9170-fw'
242
           'iwlwifi-1000-ucode'
243
           'iwlwifi-3945-ucode'
244
           'iwlwifi-4965-ucode'
245
           'iwlwifi-5000-ucode'
246
           'iwlwifi-5150-ucode'
247
           'iwlwifi-6000-ucode'
248
           'rt2870usb-fw'
249
           'rt2x00-rt61-fw'
250
           'rt2x00-rt71w-fw'
251
           'amd-ucode'
252
           'linux-firmware')
253
replaces=('kernel26-firmware'
254
          'ar9170-fw'
255
          'iwlwifi-1000-ucode'
256
          'iwlwifi-3945-ucode'
257
          'iwlwifi-4965-ucode'
258
          'iwlwifi-5000-ucode'
259
          'iwlwifi-5150-ucode'
260
          'iwlwifi-6000-ucode'
261
          'rt2870usb-fw'
262
          'rt2x00-rt61-fw'
263
          'rt2x00-rt71w-fw'
264
          'amd-ucode'
265
           'linux-firmware')
266
provides=('linux-firmware')
267
268
package() {
269
    cd "$srcdir"
270
    cp -ar ./* "$pkgdir"
271
}
272
EOF
273
sed -i -e "s/<KERNEL>/$KERNEL/g" $BDFW/PKGBUILD
274
# END PKGBUILD FOR linux-chromeboot-firmware
275
276
# Make a package for boot utilities.
277
echo "Copying utilities..."
278
mkdir -p $BDBOOT/src/usr/bin
279
mkdir -p $BDBOOT/src/usr/share/chromeboot
280
mkdir -p $BDBOOT/src/etc
281
# Copy Chrome OS' boot utilities
282
for BINARY in "${CHROMEBINS[@]}"; do
283
    cp -a "$CHROMEBIN_DIR/$BINARY" $BDBOOT/src/usr/bin
284
done
285
# If they exist, copy a few extra files so the firmware tools work
286
SHFLAGS=/usr/share/misc/shflags
287
if [ -f $SHFLAGS ]; then
288
    mkdir -p $BDBOOT/src/usr/share/misc
289
    cp -a $SHFLAGS $BDBOOT/src/usr/share/misc
290
fi
291
FLASHROM=`which flashrom 2>/dev/null`
292
DMIDECODE=`which dmidecode 2>/dev/null`
293
[[ $FLASHROM != "" ]] && cp -a "$FLASHROM" $BDBOOT/src/usr/bin
294
[[ $DMIDECODE != "" ]] && cp -a "$DMIDECODE" $BDBOOT/src/usr/bin
295
# Copy developer keys
296
cp -a $CHROME_DEVKEYB $BDBOOT/src/usr/share/chromeboot
297
cp -a $CHROME_DEVPRIVK $BDBOOT/src/usr/share/chromeboot
298
# Write chromeboot.conf based on the info we've gathered.
299
cat > $BDBOOT/src/etc/chromeboot.conf <<EOF
300
PART_KERN=$LINUXKERNDEV
301
PART_ROOT=$LINUXDEV
302
CMDLINE="$CMDLINE"
303
304
# Originally-installed CMDLINE based on Chrome OS:
305
#CMDLINE="$CMDLINE"
306
EOF
307
# Create chromeboot and chromeboot-update utils.
308
# BEGIN chromeboot SCRIPT
309
cat > $BDBOOT/src/usr/bin/chromeboot <<'EOF'
310
#!/bin/bash
311
if [[ $EUID -ne 0 ]]; then
312
    echo "This script must be run as root."
313
    exit 1
314
fi
315
316
if [ ! -f /etc/chromeboot.conf ]; then
317
    echo "/etc/chromeboot.conf not found. Aborting."
318
    exit 1
319
fi
320
321
source /etc/chromeboot.conf
322
323
ONESHOT=0
324
CHOICE="$1"
325
326
# Allow once to be written as either the first or the second param
327
if [[ $2 == once ]]; then
328
    ONESHOT=1
329
elif [[ $1 == once ]]; then
330
    ONESHOT=1
331
    CHOICE="$2"
332
fi
333
334
# Print usage if not invoked properly
335
if [ $ONESHOT -eq 1 -a $# -ne 2 ] || [ $ONESHOT -eq 0 -a $# -ne 1 ] || [ "$CHOICE" != chrome -a "$CHOICE" != linux ]; then
336
    echo "Usage: chromeboot chrome|linux [once]"
337
    echo "\"chromeboot chrome\" sets the default OS to Chrome while \"chromeboot linux\" sets it to Linux."
338
    echo "\"once\" can be added to the linux option to set the OS for the next boot only."
339
    exit 1
340
fi
341
342
# Piece together the command we want and then run it.
343
TYPE="-T 0 -S 1"
344
[[ $ONESHOT -eq 1 ]] && TYPE="-T 1 -S 0"
345
if [[ $PART_KERN =~ ([0-9a-z_/]*[a-z_/])([0-9]+)$ ]]; then
346
    # /dev/mmcblkX devices (maybe others too?) have a "p" before the partition, while /dev/sdX devices don't. Get rid of that.
347
    DISK=$( echo "${BASH_REMATCH[1]}" | sed -e 's/\([0-9]\)p$/\1/' )
348
    PART=${BASH_REMATCH[2]}
349
else
350
    echo "Unable to determine kernel partition."
351
    exit 1
352
fi
353
PRIO=5
354
[[ $CHOICE == chrome ]] && PRIO=0
355
356
CMD="cgpt add -i $PART -P $PRIO $TYPE $DISK"
357
echo $CMD
358
`$CMD`
359
360
EOF
361
# END chromeboot SCRIPT
362
# BEGIN chromeboot-update SCRIPT
363
cat > $BDBOOT/src/usr/bin/chromeboot-update <<'EOF'
364
#!/bin/bash
365
if [[ $EUID -ne 0 ]]; then
366
    echo "This script must be run as root."
367
    exit 1
368
fi
369
370
if [ ! -f /etc/chromeboot.conf ]; then
371
    echo "/etc/chromeboot.conf not found. Aborting."
372
    exit 1
373
fi
374
375
source /etc/chromeboot.conf
376
377
# Need to copy the kernel to a file on disk or else this won't work?
378
# vbutil_kernel CAN write block devices directly but they won't boot...
379
rm -rf /tmp/oldkernel /tmp/newkernel /tmp/kernelconf
380
echo "Updating kernel blob on $PART_KERN..."
381
dd if=$PART_KERN of=/tmp/oldkernel
382
echo $CMDLINE > /tmp/kernelconf
383
vbutil_kernel --repack /tmp/newkernel --oldblob /tmp/oldkernel --keyblock /usr/share/chromeboot/kernel.keyblock --version 1 --signprivate /usr/share/chromeboot/kernel_data_key.vbprivk --config /tmp/kernelconf
384
[ $? -eq 0 ] && dd if=/tmp/newkernel of=$PART_KERN
385
rm -f /tmp/oldkernel /tmp/newkernel /tmp/kernelconf
386
387
EOF
388
# END chromeboot-update SCRIPT
389
# BEGIN PKGBUILD FOR chromeboot
390
cat > $BDBOOT/PKGBUILD <<'EOF'
391
pkgname=chromeboot
392
pkgver=<KERNEL>
393
pkgrel=1
394
pkgdesc="Utilities for booting on a Chromebook."
395
arch=('x86_64')
396
url=""
397
license=('custom')
398
provides=('dmidecode')
399
conflicts=('dmidecode')
400
replaces=('dmidecode')
401
402
package() {
403
    cd "$srcdir"
404
    cp -a ./* "$pkgdir"
405
}
406
407
EOF
408
sed -i -e "s/<KERNEL>/$KERNEL/g" $BDBOOT/PKGBUILD
409
# END PKGBUILD FOR chromeboot
410
411
# Make the new scripts executable.
412
chmod +x $BDBOOT/src/usr/bin/chromeboot $BDBOOT/src/usr/bin/chromeboot-update
413
414
# Almost done! All that's left is to write a script to run in the chroot.
415
BOOTSTRAP=$BUILDDIR/bootstrap.sh
416
cat > $BOOTSTRAP <<'EOF'
417
#!/bin/bash
418
# Make-sure base-devel is installed or this won't work.
419
if [[ `pacman -Qs base-devel | wc -l` -eq 0 ]]; then
420
    echo "Error: Please install base-devel and try again."
421
    exit 1
422
fi
423
424
function checkfail {
425
    # Need to write exit status to a file because arch-chroot won't report it.
426
    [ $1 -ne 0 ] && echo $1 > /<BUILDDIR>/retcode && exit $1
427
}
428
429
# Build and install the packages. Use the -e flag since all we want to do is copy the files.
430
echo "Building 'chromeboot'..."
431
cd chromeboot
432
makepkg --asroot -ef >/dev/null
433
checkfail $?
434
echo "Installing 'chromeboot'..."
435
yes | pacman -U *.pkg.tar.xz >/dev/null
436
checkfail $?
437
echo "Building 'linux-chromeboot-firmware'..."
438
cd ../linux-chromeboot-firmware
439
makepkg --asroot -ef >/dev/null
440
checkfail $?
441
echo "Installing 'linux-chromeboot-firmware'..."
442
yes | pacman -U *.pkg.tar.xz >/dev/null
443
checkfail $?
444
echo "Building 'linux-chromeboot'..."
445
cd ../linux-chromeboot
446
makepkg --asroot -ef >/dev/null
447
checkfail $?
448
echo "Installing 'linux-chromeboot'..."
449
yes | pacman -U *.pkg.tar.xz >/dev/null
450
checkfail $?
451
452
# The linux* and mkinitcpio packages are usless now, so let's remove them.
453
echo "Removing unneeded linux packages..."
454
yes | pacman -Ru linux-docs >/dev/null 2>&1
455
yes | pacman -Ru linux-headers >/dev/null 2>&1
456
yes | pacman -Ru linux >/dev/null 2>&1
457
yes | pacman -Ru mkinitcpio >/dev/null 2>&1
458
yes | pacman -Ru mkinitcpio-busybox >/dev/null 2>&1
459
460
# Set linux to run at the next boot.
461
echo "Setting boot flag..."
462
chromeboot linux once >/dev/null
463
checkfail $?
464
echo 0 > /<BUILDDIR>/retcode
465
466
EOF
467
sed -i -e "s|<BUILDDIR>|$BUILDDIR|g" $BOOTSTRAP
468
469
# Run it.
470
echo "Building and installing packages..."
471
chmod +x $BUILDDIR/bootstrap.sh
472
if [[ $RUNPATH != "/" ]]; then
473
    eval $ARCH_CHROOT . "bash -c \"cd /$BUILDDIR && ./bootstrap.sh\""
474
else
475
    bash -c "cd /$BUILDDIR && ./bootstrap.sh"
476
fi
477
[ $? -ne 0 -o "`cat $BUILDDIR/retcode`" != "0" ] && echo "" && echo "Installation failed!" && exit 1
478
479
# Finished. Clean everything up.
480
rm -rf $BUILDDIR
481
echo ""
482
echo "Done! You can now reboot to load Arch."
483
echo "Your Arch kernel's boot configuration is stored in /etc/chromeboot.conf. To change it, first edit that file, then run chromeboot-update."
484
echo "The system's default OS is still Chrome. If you'd like to make Arch the default, run \"chromeboot linux\" within your Arch install. Try \"chromeboot\" to see more options."
485
486
# Offer to install a version of the chromeboot script for Chrome OS, unless we're in Arch or it's already been installed.
487
[[ $RUNPATH == "/" ]] || [ -x /usr/local/bin/linuxboot ] && exit 0
488
echo "Optional: install a script for Chrome OS to make switching back to Arch easier? [y/n] "
489
read EXTRAINSTALL
490
if [[ $EXTRAINSTALL == "y" || $EXTRAINSTALL == "Y" ]]; then
491
    # It has to be installed to /usr/local/bin because /bin and /usr/bin aren't writeable.
492
    mkdir -p /usr/local/bin
493
    cat > /usr/local/bin/linuxboot <<'EOF'
494
#!/bin/bash
495
496
if [[ $1 =~ ([0-9a-z_/]*[a-z_/])([0-9]+)$ ]]; then
497
    DISK=$( echo "${BASH_REMATCH[1]}" | sed -e 's/\([0-9]\)p$/\1/' )
498
    PART=${BASH_REMATCH[2]}
499
else
500
    echo "Usage: linuxboot <linux kernel partition>"
501
    echo "Sets Arch as the OS for the next boot."
502
    exit 1
503
fi
504
505
CMD="cgpt add -i $PART -P 5 -T 1 -S 0 $DISK"
506
echo $CMD
507
eval $CMD
508
509
EOF
510
    chmod +x /usr/local/bin/linuxboot
511
    echo "Done!"
512
    linuxboot
513
    echo ""
514
fi
515
echo "If you want to reinstall the packages you can do so by running this script again, either from Arch or from Chrome OS."
516
echo "If you have any problems running Arch, try playing around with your kernel parameters. Good luck!"