#!/usr/bin/env bash SYSTEM=$(uname -s) die() { echo >&2 "$@" exit 1 } [[ -n "${DAEMON_PID}" ]] || die "\$DAEMON_PID is required and must be the path of the pid file" [[ -n "${OUT_FILE}" ]] || die "\$OUT_FILE is required and must be the path of the resulting stdout" # Simplified dudeist daemonizer. Don't care about lock files, separate # stdout/stderr and fancy stuff. #YOLO case "${SYSTEM,,}" in linux) daemonize -p "${DAEMON_PID}" -e "${OUT_FILE}" -o "${OUT_FILE}" "$@" ;; freebsd) daemon -p "${DAEMON_PID}" -o "${OUT_FILE}" "$@" ;; *) die "unsupported system: ${SYSTEM}" ;; esac