#!/bin/bash

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

set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose

## On non-Qubes systems, exits 0. On Qubes systems, exits 0 if the system
## has a NetVM, 1 otherwise.

source "${HELPER_SCRIPTS_PATH:-}"/usr/libexec/helper-scripts/has.sh

if ! has qubesdb-read; then
  exit 0
fi

if ! [ -f /usr/share/qubes/marker-vm ]; then
  exit 0
fi

## Qubes sys-net does not have '/qubes-gateway'.
if qubesdb-read /qubes-netvm-gateway &>/dev/null ; then
  exit 0
fi

if qubesdb-read /qubes-gateway &>/dev/null ; then
  exit 0
fi

exit 1
