dotfiles/services/sv/goimapnotify/run

30 lines
836 B
Bash
Executable file

#!/bin/sh
# conf can take:
# CONFIG_FILE = full path to goimapnotify config file to be used
# PROFILE = name of yaml file in goimapnotify config dir (without extension)
# THROTTLE_RATE = amount of time to wait before retrying if connection fails
PROFILE="goimapnotify"
THROTTLE_RATE=10
set -e
#shellcheck disable=SC1091
[ -r ./conf ] && . ./conf
if [ "$CONFIG_FILE" != "" ]; then
config_path="$CONFIG_FILE"
else
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}"
config_path="${config_dir}/goimapnotify/${PROFILE}.yaml"
fi
# Throttle before running watcher
snooze -H /1 -M /1 -S /1 -t timefile -T "${THROTTLE_RATE}" || exit 1
touch timefile
if [ ! -f "$config_path" ]; then
echo "goimapnotify config path not found: $config_path"
exit 1
fi
exec chpst -e "$TURNSTILE_ENV_DIR" goimapnotify -conf "$config_path" 2>&1