#!/usr/bin/with-contenv bash
# shellcheck shell=bash

if [[ -f /config/core.conf ]]; then
    PUTIOARR_PORT=$(grep '"port"' /config/config.toml | tr -cd "[:digit:]")
fi

exec \
    s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 ${PUTIOARR_PORT:-9091}" \
        s6-setuidgid abc /usr/bin/putioarr run -c /config/config.toml
