#!/bin/bash

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

set -x
set -e

true "INFO: Currently running script: $BASH_SOURCE $@"

MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$MYDIR/pre"
source "$MYDIR/colors"
source "$MYDIR/variables"

main() {
   sync || true

   if [ -e "${CHROOT_FOLDER}/usr/sbin/policy-rc.d.derivative-maker" ]; then
      ## Uninstall alternative
      $SUDO_TO_ROOT chroot "${CHROOT_FOLDER}" update-alternatives --remove policy-rc.d /usr/sbin/policy-rc.d.derivative-maker

      ## Remove file
      $SUDO_TO_ROOT rm --verbose --force "${CHROOT_FOLDER}/usr/sbin/policy-rc.d.derivative-maker"
   fi

   sync || true
}

main "$@"
