security-misc/usr/libexec/security-misc/cold-boot-attack-defense-kexec-prepare
Patrick Schleizer 2cc3c6c59c
lower debugging
2023-01-07 15:04:42 -05:00

43 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
## Copyright (C) 2023 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## Copyright (C) 2023 - 2023 Friedrich Doku <friedrichdoku@gmail.com>
## See the file COPYING for copying conditions.
set -x
set -e
# Get the kernel command-line arguments
cmdline=$(cat /proc/cmdline)
# Get the current boot image
kernel=$(echo "$cmdline" | grep -o 'BOOT_IMAGE=\S*' | cut -d '=' -f 2)
initrd=$(echo "$kernel" | sed "s#vmlinuz#initrd.img#")
if test -e $initrd; then
echo "$0: INFO: Initrd File Found"
else
echo "$0: ERROR: Initrd File NOT FOUND"
exit 1
fi
if test -e $kernel; then
echo "$0: INFO: Kernel File Found"
else
echo "$0: ERROR: Kernel File NOT FOUND"
exit 1
fi
if systemctl list-jobs | grep "poweroff.target" | grep -q "start"; then
wram="yes"
wact="poweroff"
elif systemctl list-jobs | grep "reboot.target" | grep -q "start"; then
wram="yes"
wact="reboot"
elif systemctl list-jobs | grep "halt.target" | grep -q "start"; then
wram="yes"
wact="halt"
else
echo "$0: ERROR: No shutdown option found!"
exit 0
fi
kexec -l $kernel --initrd=$initrd --reuse-cmdline --append="wiperamexit=$wram wiperamaction=$wact"