#!/bin/sh
# relx pre_start hook, sourced by bin/hearth before the node starts.
#
# `bin/hearth daemon' (and the deprecated `start') would run the node
# under run_erl and write its console output to log/erlang.log.N, a file
# created with the default mode (0644). The start link is printed to
# that console, so every local user could read it and open a session.
# Those modes are refused; `foreground' and `console' keep the link in
# the terminal of the user who started Hearth. The hook is sourced with
# HEART_OPTION set only on the daemon path.
case "${HEART_OPTION:-}" in
  daemon|daemon_boot)
    echo "Hearth kör inte som daemon: startlänken skulle hamna i en logg som andra användare kan läsa." >&2
    echo "Starta med 'bin/hearth foreground' (eller 'bin/hearth console')." >&2
    exit 1
    ;;
esac
