#!/bin/bash

## Copyright (C) 2023 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

#set -x
#set -e

true "$0: START"

drop_caches() {
   sync
   ## https://gitlab.tails.boum.org/tails/tails/-/blob/master/config/chroot_local-includes/usr/local/lib/initramfs-pre-shutdown-hook
   ### Ensure any remaining disk cache is erased by Linux' memory poisoning
   echo 3 > /proc/sys/vm/drop_caches
   sync
}

drop_caches

## TODO: sdmem settings. One pass only. Secure? Configurable?
## TODO: > /dev/kmsg 2> /dev/kmsg
sdmem -l -l -v

drop_caches

true "$0: END"
