#!/bin/bash

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

if [ -f /usr/libexec/helper-scripts/pre.bsh ]; then
   source /usr/libexec/helper-scripts/pre.bsh
fi

set -e

true "
#####################################################################
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

etc_machine_id_modify() {
   if [ -f "/var/lib/anon-base-files/do_once/${FUNCNAME}_version_1" ]; then
      return 0
   fi

   ## Prevent the following question.
   # Setting up anon-base-files (3:5.3-1) ...
   #
   # Configuration file '/etc/machine-id'
   #  ==> File on system created by you or by a script.
   #  ==> File also in package provided by package maintainer.
   #    What would you like to do about it ?  Your options are:
   #     Y or I  : install the package maintainer's version
   #     N or O  : keep your currently-installed version
   #       D     : show the differences between the versions
   #       Z     : start a shell to examine the situation
   #  The default action is to keep your current version.
   # *** machine-id (Y/I/N/O/D/Z) [default=N] ?

   machine_id_wanted="b08dfa6083e7567a1921a715000001fb"
   if test -f "/etc/machine-id" ; then
      current="$(cat "/etc/machine-id")" || true
      if [ ! "$current" = "$machine_id_wanted" ]; then
         echo "$machine_id_wanted" | tee "/etc/machine-id" >/dev/null || true
      fi
   fi

   mkdir --parents "/var/lib/anon-base-files/do_once"
   touch "/var/lib/anon-base-files/do_once/${FUNCNAME}_version_1"
}

etc_machine_id_modify

true "INFO: debhelper beginning here."



true "INFO: Done with debhelper."

true "
#####################################################################
## INFO: END  : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Explicitly "exit 0", so eventually trapped errors can be ignored.
exit 0
