#!/usr/bin/env bash

set -o pipefail

source $(realpath -m ..)/.vars.conf
source $(realpath -m ..)/.hosts.conf

nfs_server_dir=/data/.nfs-fileshare


# 渲染 YAML 配置文件
for yaml in nfs-provisioner.yaml
do
    envsubst < $(realpath -m ..)/yamls/${yaml} >${install_dir}/${yaml}
done

[[ -d ${nfs_server_dir} ]] || mkdir -p ${nfs_server_dir}

yum -y install nfs-utils

cat >/etc/exports<<EOF
${nfs_server_dir} *(rw,async,crossmnt,insecure,fsid=0,no_auth_nlm,no_subtree_check,no_root_squash,no_all_squash)
EOF

systemctl enable nfs-server --now
