diff --git a/README.md b/README.md index 9f19b17a..759ef3cf 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,15 @@ When this finishes, the bin file in the path you provided will have been convert After injecting, you may continue to the "[Booting Into A Shim](#booting-into-a-shim)" section. +#### Preseeding + +Once you've built a legacy shim, you can also 'preseed' it to run a shell script on boot rather than opening the menu: +```shell +sudo ./wax/inject_preseed.sh -s -p +``` +Preseed files can call any function defined in [factory_install.sh](https://github.com/MercuryWorkshop/sh1mmer/blob/beautifulworld/wax/sh1mmer_legacy/root/noarch/usr/sbin/factory_install.sh). See [here](https://github.com/MercuryWorkshop/sh1mmer/tree/beautifulworld/wax/preseed/examples) for examples. + + *** ### Booting Into A Shim @@ -108,6 +117,7 @@ From here, you can play around with the options and do what you want. *** + ### The Fog.... Downgrading and unenrollment has been patched by Google™️. diff --git a/wax/inject_preseed.sh b/wax/inject_preseed.sh new file mode 100755 index 00000000..38f8a9d0 --- /dev/null +++ b/wax/inject_preseed.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# TODO: properly error out/notify when run on a modern or raw shim + +SCRIPT_DIR=$(dirname "$0") +SCRIPT_DIR=${SCRIPT_DIR:-"."} +. "$SCRIPT_DIR/lib/wax_common.sh" + +PRESEED_FILENAME="usr/sbin/preseed.sh" + +set -eE + +[ "$EUID" -ne 0 ] && fail "Please run as root" +missing_deps=$(check_deps partx sgdisk mkfs.ext4 mkfs.ext2 e2fsck resize2fs file) +[ -n "$missing_deps" ] && fail "The following required commands weren't found in PATH:\n${missing_deps}" + +cleanup () { + log_debug "cleaning up..." + [ -z "$LOOPDEV" ] || losetup -d "$LOOPDEV" || : + trap - EXIT INT +} + +trap 'echo $BASH_COMMAND failed with exit code $?. THIS IS A BUG, PLEASE REPORT!' ERR +trap 'cleanup; exit' EXIT +trap 'echo Abort.; cleanup; exit' INT + +cat <