Skip to content

Commit

Permalink
fixed everything i broke, but revert not working either
Browse files Browse the repository at this point in the history
  • Loading branch information
velzie committed Mar 2, 2023
1 parent 8896ae7 commit 4b940d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions chromeos_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if [ ! -f /sshd_staged ]; then
ssh-keygen -f /ssh/root/key -N '' -t rsa >/dev/null
cp /ssh/root/key /rootkey
chmod 600 /ssh/root
chmod 644 /ssh/rootkey

cat >/ssh/config <<-EOF
AuthorizedKeysFile /ssh/%u/key.pub
Expand Down
44 changes: 37 additions & 7 deletions fakemurk.sh.pre
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,20 @@ move_bin() {
}

is_target_booted() {
[ -z "$COMPAT" ] && [ "$TGT_ROOT_DEV" == "$ROOTDEV" ]
[ -z "$COMPAT" ] && [ "$(get_booted_kernnum)" == "$TGT_KERNNUM" ]
}
opposite_num() {
if [ "$1" == "2" ]; then
echo -n 4
elif [ "$1" == "4" ]; then
echo -n 2
elif [ "$1" == "3" ]; then
echo -n 5
elif [ "$1" == "5" ]; then
echo -n 3
else
return 1
fi
}

disable_autoupdates() {
Expand All @@ -254,6 +267,7 @@ EOF
swallow_stdin
read -r
reboot
leave
fi
fi

Expand All @@ -269,7 +283,13 @@ EOF
verity_enabled_for_n() {
grep -q "root=/dev/dm" <"${DST}p${1}"
}

get_booted_kernnum() {
if (($(cgpt show -n "$DST" -i 2 -P) > $(cgpt show -n "$DST" -i 4 -P))); then
echo -n 2
else
echo -n 4
fi
}
cleanup() {

if [ "$COMPAT" == "1" ]; then
Expand All @@ -295,30 +315,40 @@ configure_target() {
fi

if verity_enabled_for_n 2 && verity_enabled_for_n 4; then
:
TGT_KERNNUM=
elif verity_enabled_for_n 2; then
TGT_KERNNUM=4
elif verity_enabled_for_n 4; then
TGT_KERNNUM=2
else
TGT_KERNNUM=
if [ "$ROOTFS_BACKUP" == "1" ]; then
echo "Rootfs restore is requested to be enabled, but both partitions have rootfs verification disabled. Please go through the recovery process to enable rootfs verification or run again and do not choose to enable rootfs restore."
leave
fi
fi

if [ -z "$TGT_KERNNUM" ]; then
if [ "$TGT_KERNNUM" != "2" ] && [ "$TGT_KERNNUM" != "4" ]; then
if [ "$COMPAT" == "1" ]; then
TGT_KERNNUM=2
# 2 is the default simply because it's easier
else
ROOTDEV=$(rootdev)
TGT_KERNNUM=${ROOTDEV:(-1)}
TGT_KERNNUM=$(opposite_num "$(get_booted_kernnum)")
fi
fi
TGT_ROOTNUM=$((TGT_KERNNUM + 1))
TGT_KERN_DEV="${DST}p$TGT_KERNNUM"
TGT_ROOT_DEV="${DST}p$TGT_ROOTNUM"

ALT_ROOTNUM=$(opposite_num "$TGT_ROOTNUM")
ALT_KERNNUM=$(opposite_num "$TGT_KERNNUM")
ALT_KERN_DEV="${DST}p$ALT_KERNNUM"
ALT_ROOT_DEV="${DST}p$ALT_ROOTNUM"

echo "target kern is $TGT_KERNNUM@$TGT_KERN_DEV"
echo "target root is $TGT_ROOTNUM@$TGT_ROOT_DEV"
echo
echo "backup kern is $ALT_KERNNUM@$ALT_KERN_DEV"
echo "backup root is $ALT_ROOTNUM@$ALT_ROOT_DEV"
}

patch_root() {
Expand Down
4 changes: 2 additions & 2 deletions pollen.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"ReportDeviceOsUpdateStatus": false,
"VpnConfigAllowed": true,
"UnaffiliatedArcAllowed": true,
"AllowedDomainsForApps": "addyourschooldomain.edu,consumer_accounts"
}
"AllowedDomainsForApps": "__SED_REPLACEME_SCHOOL_EMAIL__,consumer_accounts"
}

0 comments on commit 4b940d9

Please sign in to comment.