improve crossystem implementation

This commit is contained in:
ading2210 2023-11-10 23:49:59 -08:00
parent 9064700b0f
commit 58faaa5b1d
4 changed files with 32 additions and 32 deletions

View File

@ -81,7 +81,7 @@ Driver support depends on the device you are using shimboot on. This list is for
3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the [sh1mmer website](https://sh1mmer.me) (see the "Executing on Chromebook" section).
4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader.
5. Boot into Debian and log in with the username and password that you configured earlier. The default username/password for the prebuilt images is `user/user`.
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX` to expand the filesystem.
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX4` to expand the filesystem.
## FAQ:

View File

@ -243,7 +243,7 @@ get_donor_selection() {
if [ "$selection" = "$i" ]; then
echo "selected $part_path as the donor partition"
read -p "would you like to spoof verfied mode? this is useful if you're planning on using chrome os while enrolled. (y/n): " use_crossystem
read -p "would you like to spoof verified mode? this is useful if you're planning on using chrome os while enrolled. (y/n): " use_crossystem
if [ "$use_crossystem" = "y" ] || [ "$use_crossystem" = "n" ]; then
boot_chromeos $target $part_path $use_crossystem
@ -306,9 +306,12 @@ boot_chromeos() {
rm -rf $donor_mount
if [ -e "/newroot/etc/init/tpm-probe.conf" ]; then
echo "hiding the tpm from upstart"
echo "applying chrome os flex patches"
mkdir -p /newroot/tmp/empty
mount -o bind /newroot/tmp/empty /sys/class/tpm
cat /newroot/etc/lsb-release | sed "s/DEVICETYPE=OTHER/DEVICETYPE=CHROMEBOOK/" > /newroot/tmp/lsb-release
mount -o bind /newroot/tmp/lsb-release /newroot/etc/lsb-release
fi
echo "patching chrome os rootfs"

View File

@ -3,27 +3,23 @@
#a much cleaner implemenation of fakemurk's crossystem.sh
crossystem_old=/tmp/crossystem_old
crossystem_dict="cros_debug 0
dev_boot_legacy 0
dev_boot_signed_only 1
dev_boot_usb 0
devsw_boot 0
devsw_cur 0
block_devmode 1
mainfw_act A
mainfw_type normal
recovery_reason 0
recovery_request 0
recoverysw_boot 0
recoverysw_cur 0"
dict_set() {
local newline=$'\n'
crossystem_dict="$crossystem_dict$newline$1 $2"
}
declare -A crossystem_dict=(
["cros_debug"]="1"
["dev_boot_legacy"]="0"
["dev_boot_signed_only"]="1"
["devsw_boot"]="0"
["devsw_cur"]="0"
["block_devmode"]="1"
["mainfw_act"]="A"
["mainfw_type"]="normal"
["recovery_reason"]="0"
["recovery_request"]="0"
["recoverysw_boot"]="0"
["recoverysw_cur"]="0"
)
dict_get() {
echo "$crossystem_dict" | grep "^$1 " | cut -d " " -f 2-
echo "${crossystem_dict[$1]}"
}
parse_arg() {
@ -37,13 +33,13 @@ parse_arg() {
elif [[ "$arg" =~ "?" ]]; then
key=$(echo $arg | cut -d "?" -f 1)
query=$(echo $arg | cut -d "?" -f 2)
if ! [ "$(dict_get $key)" = "$query" ]; then
if ! [ "${crossystem_dict[$key]}" = "$query" ]; then
exit 1
fi
#get value mode
elif [ "$(dict_get $arg)" ]; then
printf "$(dict_get $arg)"
elif [ "${crossystem_dict[$arg]}" ]; then
printf "${crossystem_dict[$arg]}"
#value not found - print help and exit
else
@ -60,18 +56,19 @@ while IFS= read -r line; do
line=$(echo $line | cut -d "#" -f 1)
key=$(echo $line | cut -d "=" -f 1 | xargs)
value=$(echo $line | cut -d "=" -f 2 | xargs)
if [ -z "$(dict_get $key)" ]; then
dict_set "$key" "$value"
if [ -z "${crossystem_dict[$key]}" ]; then
crossystem_dict["$key"]="$value"
fi
done <<< "$crossystem_out"
#crossystem called with no arguments, print out all properties
if [ -z "$1" ] || [ "$1" = "--all" ]; then
while IFS= read -r line; do
key=$(echo $line | cut -d " " -f 1)
value=$(echo $line | cut -d " " -f 2-)
keys="${!crossystem_dict[@]}"
keys="$(echo "$keys" | tr " " "\n" | sort)"
for key in $keys; do
value="${crossystem_dict[$key]}"
echo "$key = $value"
done <<< "$crossystem_dict"
done
exit 0
fi

View File

@ -87,7 +87,7 @@ For these images, the root password is "root". The name of the default user is "
3. Enable developer mode on your Chromebook. If the Chromebook is enrolled, follow the instructions on the <a href="https://sh1mmer.me">sh1mmer website</a> (see the "Executing on Chromebook" section).
4. Plug the USB into your Chromebook and enter recovery mode. It should detect the USB and run the shimboot bootloader.
5. Boot into Debian and log in with the username and password that you configured earlier. The default username/password for the prebuilt images is `user/user`.
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX` to expand the filesystem.
6. Expand the rootfs partition so that it fills up the entire disk by running `sudo growpart /dev/sdX 4` (replacing `sdX` with the block device corresponding to your disk) to expand the partition, then running `sudo resize2fs /dev/sdX4` to expand the filesystem.
<b id="copyright">Copyright:</b>
Shimboot is licensed under the <a href="https://www.gnu.org/licenses/gpl-3.0.txt">GNU GPL v3</a>. Unless otherwise indicated, all code has been written by me, <a href="https://ading.dev">ading2210</a>.