#!/usr/bin/env bash
# SPDX-License-Identifier: LicenseRef-Proprietary
# Copyright (c) 2026 MinIO, Inc. All rights reserved.
#
# AIStor Files — the product daemon. A thin white-label wrapper over the upstream
# NFS-Ganesha binary (LGPL): it brands --help/--version and runs the daemon under
# the name `files` (via exec -a), so the shipped/served binary is `files`, not
# `ganesha.nfsd`. All other arguments pass straight through to Ganesha.
set -euo pipefail

case "${1:-}" in
-h | --help)
	cat <<'USAGE'
AIStor Files — native NFSv4.1 gateway for MinIO AIStor

usage: files [options]
  -F                 run in foreground (do not daemonize)
  -f <conf>          configuration file
  -L <log>           log file
  -N <level>         log level (e.g. NIV_EVENT)
  -p <pidfile>       pid file

Files owns its own POSIX namespace and tiers file data to AIStor as 16 MiB
objects. Runtime is a white-labeled NFS-Ganesha with the FILES FSAL.
USAGE
	exit 0
	;;
-V | --version)
	# The version/build placeholders below are stamped at build time by
	# crates/ffi/build.rs (the substituted copy is what packaging installs;
	# a raw run of the checked-in template prints them literally).
	echo "AIStor Files 0.0.1 (NFSv4.1 gateway, build 11.0.0-edge)"
	exit 0
	;;
esac

exec -a files ganesha.nfsd "$@"
