#!/bin/sh
# The owner's first sign-in, shown on every SSH login (/etc/update-motd.d/90-perpetua) and
# once on the server's console by firstboot.sh (M1). It never prints the password: an SSH
# login is not always the owner's, and a cloud keeps its console log. The password stays in
# a file only root can read.

SITE="$(sed -n "s/^PERPETUA_APP_URL=//p" "${PERPETUA_ENV_FILE:-/etc/perpetua/perpetua.env}" 2>/dev/null)"

echo
echo "CreekX is running on this server${SITE:+: $SITE}"
echo
echo "  Your first sign-in (email and password) is in /root/perpetua-first-sign-in.txt,"
echo "  readable by root only. To see it:"
echo "    sudo cat /root/perpetua-first-sign-in.txt"
echo "  CreekX asks you to choose your own password the first time you sign in."
echo
case "$SITE" in
  https://*) ;;
  *)
    echo "  To use https (going live from a browser needs it), add a domain:"
    echo "    1. In your domain's DNS settings, point an A record (e.g. live.example.com)"
    echo "       at this server's public IP address, and open ports 80 and 443."
    echo "    2. sudo creekx domain live.example.com"
    echo
    ;;
esac
echo "  Look after it: sudo creekx status | logs | backup | upgrade FILE"
echo
