qusal/salt/mail/files/fetcher/bin/qusal-send-inbox
Ben Grande bdd4c789c1
fix: avoid echo usage
Echo can interpret operand as an option and checking every variable to
be echoed is troublesome while with printf, if the format specifier is
present before the operand, printing as string can be enforced.
2024-08-06 18:15:24 +02:00

26 lines
612 B
Bash
Executable File

#!/bin/sh
## SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
inbox_dir="${HOME}/mail/INBOX"
if test ! -d "${inbox_dir}"; then
printf '%s\n' "Inbox '${inbox_dir}' does not exist" >&2
exit 1
fi
cd "${inbox_dir}" || exit 1
files_to_send="$(find "${inbox_dir}" -type f)"
if test -z "${files_to_send}"; then
printf '%s\n' "Inbox '${inbox_dir}' is empty" >&2
exit 1
fi
qrexec-client-vm --filter-escape-chars-stderr -- @default qusal.MailFetch \
/usr/lib/qubes/qfile-agent *
find "${inbox_dir}" -type f -delete