Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DAUB payload and improve Weston #151

Open
wants to merge 2 commits into
base: beautifulworld
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions wax/payloads/daub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
# DAUB - Depthcharge Automatic Update Blocker - Written with love by Hannah <3

function panic() {
echo -ne "\e[1;31mFatal Error: $1\e[0m"
sleep 1
exit 1
}

function get_largest_cros_blockdev() {
local largest size dev_name tmp_size remo
size=0
for blockdev in /sys/block/*; do
dev_name="${blockdev##*/}"
echo "$dev_name" | grep -q '^\(loop\|ram\)' && continue
tmp_size=$(cat "$blockdev"/size)
remo=$(cat "$blockdev"/removable)
if [ "$tmp_size" -gt "$size" ] && [ "${remo:-0}" -eq 0 ]; then
case "$(sfdisk -d "/dev/$dev_name" 2>/dev/null)" in
*'name="STATE"'*'name="KERN-A"'*'name="ROOT-A"'*)
largest="/dev/$dev_name"
size="$tmp_size"
;;
esac
fi
done
echo "$largest"
}

function find_inactive_parts() {
local disk="$1"
local kern_a_priority=$(cgpt show "$disk" -i 2 -P)

if [ "$kern_a_priority" == "1" ] || [ "$kern_a_priority" == "2" ]; then
inactive_kern=4
inactive_root=5
else
inactive_kern=2
inactive_root=3
fi
}

function main() {
local disk=$(get_largest_cros_blockdev)
[ -z "$disk" ] && panic "No CrOS SSD found on device!"

echo "Searching for inactive partitions."
find_inactive_parts "$disk"

echo "Deleting updatable partitions."
(
echo "d"
echo "$inactive_kern"
echo "d"
echo "$inactive_root"

echo "w"
) | fdisk "$disk" 2>/dev/null

echo "Formatting stateful."
mkfs.ext4 -F -b 4096 -L H-STATE "${disk}p1" >/dev/null 2>&1

echo "Done!"
return 0
}

if [ "$0" == "$BASH_SOURCE" ]; then
main "$@"
fi
1 change: 1 addition & 0 deletions wax/sh1mmer_bw/root/noarch/usr/sbin/sh1mmer_payload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ run_task() {

mapname() {
case "$(basename "$1")" in
'daub.sh') echo -n "Remove the backup partitions and prevent autoupdates" ;;
'autoupdate.sh') echo -n "Fetch updated payloads. REQUIRES WIFI (not working)" ;;
'caliginosity.sh') echo -n "Revert all changes made by sh1mmer (reenroll + more)" ;;
'crap.sh') echo -n "CRAP - ChromeOS Automated Partitioning" ;;
Expand Down
1 change: 1 addition & 0 deletions wax/sh1mmer_legacy/root/noarch/usr/sbin/sh1mmer_payload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ run_task() {

mapname() {
case "$(basename "$1")" in
'daub.sh') echo -n "Remove the backup partitions and prevent autoupdates" ;;
'autoupdate.sh') echo -n "Fetch updated payloads. REQUIRES WIFI (not working)" ;;
'caliginosity.sh') echo -n "Revert all changes made by sh1mmer (reenroll + more)" ;;
'crap.sh') echo -n "CRAP - ChromeOS Automated Partitioning" ;;
Expand Down