diff options
author | mediocregopher <mediocregopher@gmail.com> | 2023-08-13 21:34:14 +0200 |
---|---|---|
committer | mediocregopher <mediocregopher@gmail.com> | 2023-08-13 21:35:17 +0200 |
commit | 1957081c122fe231eb6120192489dd979d214317 (patch) | |
tree | b8cd0812ec3c0452d54cb789ba938e6f0c0e8278 /bin/quick-shutdown | |
parent | ef8da74f1ae38d9eceb68846fe9ef402c8e30fcf (diff) |
Update branch with all changes which could be brought in from private branches
For a while I was keeping a private branch where there were a lot of
non-public things included, and that became the de-facto branch while
this one lagged. This one is now up-to-date, all private stuff is dealt
with via config files which are not committed.
Diffstat (limited to 'bin/quick-shutdown')
-rwxr-xr-x | bin/quick-shutdown | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/quick-shutdown b/bin/quick-shutdown new file mode 100755 index 0000000..f5a5259 --- /dev/null +++ b/bin/quick-shutdown @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +# This assumes that /proc/cmdline contains a cryptdevice with a UUID identifier, +# like: +# +# cryptdevice=UUID=1ff1d6f7-7540-4500-8011-1abe1e9ac00d:cryptroot +uuid=$(cat /proc/cmdline | \ + tr ' ' '\n' | \ + grep cryptdevice | \ + cut -d= -f3 | \ + cut -d: -f1) + +device=$(lsblk -o PATH,UUID | grep "$uuid" | awk '{print $1}') +echo "Root device is $device" + +echo -n "Enter root key: " +read -s pw +echo "" + +# This will check if the key is right, and cause the process to exit if not due +# to the "set -e" +echo "Checking key..." +echo "$pw" | sudo cryptsetup open --test-passphrase "$device" + +echo "Good job, writing /boot/keyfile..." +echo -n "$pw" | sudo tee /boot/keyfile >/dev/null + +echo "Shutting down..." +sudo systemctl poweroff |