feat: ADD work with local .env file #14
This commit is contained in:
parent
30e6956fa4
commit
d0373f0198
4 changed files with 81 additions and 0 deletions
17
build.sh
17
build.sh
|
|
@ -10,6 +10,20 @@ OUTPUT_DIR="output"
|
|||
TEMPLATES_DIR="templates"
|
||||
ASSETS_DIR="assets"
|
||||
|
||||
# Load .env if present; see .env.example for every option and its default.
|
||||
# Precedence: command line flags > environment > .env > built-in defaults.
|
||||
ENV_FILE="${ENV_FILE:-.env}"
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
# Remember caller-supplied values so the file cannot clobber them
|
||||
env_override=$(export -p | grep -E '^declare -x (STRIP_EXIF|GALLERY_TITLE|SHOW_FOOTER)=' || true)
|
||||
# shellcheck source=/dev/null
|
||||
source "$ENV_FILE"
|
||||
if [[ -n "$env_override" ]]; then
|
||||
eval "$env_override"
|
||||
fi
|
||||
unset env_override
|
||||
fi
|
||||
|
||||
# Image metadata (EXIF/GPS/IPTC/XMP) is stripped by default.
|
||||
# Opt out with STRIP_EXIF=0 or --keep-exif.
|
||||
STRIP_EXIF="${STRIP_EXIF:-1}"
|
||||
|
|
@ -30,6 +44,9 @@ for arg in "$@"; do
|
|||
echo " --keep-exif do not strip image metadata (env: STRIP_EXIF=0)"
|
||||
echo " --no-footer hide the 'Powered by shellery' footer (env: SHOW_FOOTER=0)"
|
||||
echo " --title=TEXT page title and header, default 'Gallery' (env: GALLERY_TITLE)"
|
||||
echo ""
|
||||
echo "Options may also be set in .env (see .env.example)."
|
||||
echo "Precedence: flags > environment > .env > defaults."
|
||||
exit 0 ;;
|
||||
*) echo "unknown option: $arg" >&2; exit 1 ;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue