add an option to spoof verified mode in cros
This commit is contained in:
parent
2b398f762d
commit
9064700b0f
|
@ -243,8 +243,16 @@ get_donor_selection() {
|
|||
|
||||
if [ "$selection" = "$i" ]; then
|
||||
echo "selected $part_path as the donor partition"
|
||||
boot_chromeos $target $part_path
|
||||
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
|
||||
|
||||
if [ "$use_crossystem" = "y" ] || [ "$use_crossystem" = "n" ]; then
|
||||
boot_chromeos $target $part_path $use_crossystem
|
||||
return 0
|
||||
else
|
||||
echo "invalid selection"
|
||||
sleep 1
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
i=$((i+1))
|
||||
|
@ -272,6 +280,7 @@ boot_target() {
|
|||
boot_chromeos() {
|
||||
local target="$1"
|
||||
local donor="$2"
|
||||
local use_crossystem="$3"
|
||||
|
||||
echo "mounting target"
|
||||
mkdir /newroot
|
||||
|
@ -306,6 +315,13 @@ boot_chromeos() {
|
|||
cat /newroot/etc/ui_use_flags.txt | sed "/reven_branding/d" | sed "/os_install_service/d" > /newroot/tmp/ui_use_flags.txt
|
||||
mount -o bind /newroot/tmp/ui_use_flags.txt /newroot/etc/ui_use_flags.txt
|
||||
|
||||
if [ "$use_crossystem" = "y" ]; then
|
||||
echo "patching crossystem"
|
||||
cp /opt/crossystem /newroot/tmp/crossystem
|
||||
cp /newroot/usr/bin/crossystem /newroot/tmp/crossystem_old
|
||||
mount -o bind /newroot/tmp/crossystem /newroot/usr/bin/crossystem
|
||||
fi
|
||||
|
||||
echo "moving mounts"
|
||||
move_mounts /newroot
|
||||
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
|
||||
#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"
|
||||
}
|
||||
|
||||
dict_get() {
|
||||
echo "$crossystem_dict" | grep "^$1 " | cut -d " " -f 2-
|
||||
}
|
||||
|
||||
parse_arg() {
|
||||
local arg="$1"
|
||||
|
||||
#set values mode - pass this through without changes
|
||||
if [[ "$arg" =~ "=" ]]; then
|
||||
$crossystem_old "$@"
|
||||
|
||||
#search value mode
|
||||
elif [[ "$arg" =~ "?" ]]; then
|
||||
key=$(echo $arg | cut -d "?" -f 1)
|
||||
query=$(echo $arg | cut -d "?" -f 2)
|
||||
if ! [ "$(dict_get $key)" = "$query" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#get value mode
|
||||
elif [ "$(dict_get $arg)" ]; then
|
||||
printf "$(dict_get $arg)"
|
||||
|
||||
#value not found - print help and exit
|
||||
else
|
||||
$crossystem_old --help
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
crossystem_out="$($crossystem_old)"
|
||||
#crossystem_out=$(cat data/crossystem.txt)
|
||||
|
||||
#add crossystem output to the dict
|
||||
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"
|
||||
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-)
|
||||
echo "$key = $value"
|
||||
done <<< "$crossystem_dict"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for arg in "$@"; do
|
||||
parse_arg $arg
|
||||
done
|
Loading…
Reference in New Issue