Files
security-misc/usr/libexec/security-misc/cold-boot-attack-defense-kexec-prepare
2023-01-06 21:32:57 -05:00

53 lines
1.2 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
true "env:"
env
## Debugging.
## Lets hope $1 is set to reboot, poweroff or halt by systemd.
true "1: $1"
initrd=/boot/initrd.img-$(uname -r)
kernel=/boot/vmlinuz-$(uname -r)
if test -e $initrd; then
echo "Initrd File Found"
else
echo "Initrd File NOT FOUND"
exit 1
fi
if test -e $kernel; then
echo "Kernel File Found"
else
echo "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"
elif systemctl list-jobs | grep "kexec.target" | grep -q "start"; then
wram="yes"
wact="kexec"
else
echo "Error no shutdown option found!"
wram="yes"
wact="error"
fi
kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initrd.img-$(uname -r) --reuse-cmdline --append="wiperamexit=$wram wiperamaction=$wact"