2022-03-09 13:45:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
SYSTEM=$(uname -s)
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo >&2 "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2022-06-13 19:54:47 +00:00
|
|
|
[[ -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"
|
|
|
|
|
2022-03-09 13:45:36 +00:00
|
|
|
# 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}" "$@"
|
|
|
|
;;
|
|
|
|
*)
|
2022-06-13 19:54:47 +00:00
|
|
|
die "unsupported system: ${SYSTEM}"
|
2022-03-09 13:45:36 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|