#!/bin/bash

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

## /etc/bash.bash_logout

## Terminate msgdispatcher --cli when logging out from tty1.

source /usr/libexec/msgcollector/msgcollector_shared
## sets: ${msgcollector_run_dir}
folder_init

if [ ! "$(tty)" = "/dev/tty1" ]; then
   true
else
   if [ -f "${msgcollector_run_dir}/msgdispatcher_pidcli" ]; then
      pid="$(cat "${msgcollector_run_dir}/msgdispatcher_pidcli")"
      if [ ! "$pid" = "" ]; then
         kill -s sigterm "$pid"
      fi
   fi
fi

## End of /etc/bash.bash_logout
