#!/bin/sh

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

#set -x

true "user-sysmaint-split $0: START"

set -e
set -o allexport

make_boot_entry='true'

: "${persistence_type:="PERSISTENT"}"
: "${session_detail:="system maintenance tasks"}"

grub_distributor_appendix="$persistence_type Mode | SYSMAINT Session | $session_detail"
if [ -e '/usr/share/kicksecure/marker' ]; then
   GRUB_DISTRIBUTOR="$grub_distributor_appendix"
elif [ -e '/usr/share/anon-ws-base-files/workstation' ]; then
   GRUB_DISTRIBUTOR="$grub_distributor_appendix"
elif [ -e '/usr/share/anon-gw-base-files/gateway' ]; then
   GRUB_DISTRIBUTOR="$grub_distributor_appendix"
else
   GRUB_DISTRIBUTOR="$grub_distributor_appendix"
fi

GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX boot-role=sysmaint systemd.unit=sysmaint-boot.target"

if test -x /etc/grub.d/10_00_linux_dist ; then
	/etc/grub.d/10_00_linux_dist
fi

true "user-sysmaint-split $0: OK: END"
