#!/usr/bin/env bash
set -eu

echo " + Cloning letsencrypt.sh git repository..."
git submodule init
git submodule update

echo " + Setting challenge directory..."
mkdir -p "${DOCUMENT_ROOT}/.well-known/acme-challenge"
echo "WELLKNOWN='${DOCUMENT_ROOT}/.well-known/acme-challenge'" > letsencrypt.sh/config

echo " + Installing hook script..."
chmod +x nfsn-hook.sh
echo "HOOK='$(realpath nfsn-hook.sh)'" >> letsencrypt.sh/config

echo " + Generating domains.txt..."
nfsn -s list-aliases > letsencrypt.sh/domains.txt

echo " + Performing initial run..."
letsencrypt.sh/letsencrypt.sh --cron

user_site=${MAIL##*/}
echo " + Done! Now add $(realpath nfsn-cron.sh) to your scheduled tasks!"
echo "   You can find them at https://members.nearlyfreespeech.net/${user_site%_*}/sites/${NFSN_SITE_NAME}/cron"
echo "   letsencrypt.sh will not try and renew the script unless it expires in less than 30 days."
echo "   I recommend running it daily, to ensure plenty of warning if the renewal fails."

#!/usr/bin/env bash
set -eu

echo " + Cloning letsencrypt.sh git repository..."
git submodule init
git submodule update

echo " + Setting challenge directory..."
mkdir -p "${DOCUMENT_ROOT}/.well-known/acme-challenge"
echo "WELLKNOWN='${DOCUMENT_ROOT}/.well-known/acme-challenge'" > letsencrypt.sh/config

echo " + Installing hook script..."
chmod +x nfsn-hook.sh
echo "HOOK='$(realpath nfsn-hook.sh)'" >> letsencrypt.sh/config

echo " + Generating domains.txt..."
nfsn -s list-aliases > letsencrypt.sh/domains.txt

echo " + Performing initial run..."
letsencrypt.sh/letsencrypt.sh --cron

user_site=${MAIL##*/}
printf '
   Now add nfsn-cron.sh to your scheduled tasks so that the certificates will be
   renewed automatically.  To do that, go to

       https://members.nearlyfreespeech.net/%s/sites/%s/cron

   and use the following settings:

       Tag:                  lets-nfsn
       URL or Shell Command: %q %q
       User:                 me
       Hour:                 %d
       Day of Week:          Every
       Date:                 *

   The certificates will be renewed only when needed so it’s safe to schedule
   the task to run daily.
' \
       "${user_site%_*}" "$NFSN_SITE_NAME" \
       "$BASH" "$(realpath nfsn-cron.sh)" \
       "$(( $RANDOM % 24 ))"

Make post-setup instructions more detailed
Make post-setup instructions more detailed

Also, since we’re using bash, make use of printf’s %q format to properly
escape strings in the shell command.
