#!/bin/sh
if grep -q VEIL /etc/exports 2>/dev/null; then
	echo "NFS Server configured"
	exit 0
fi

for i in /storages/nfs /storages/nfs931 /storages/nfsn; do
	[ ! -d ${i} ] && mkdir -p ${i}
done

cat > /etc/exports <<EOF
# VEIL
"/storages/nfs" *(rw,insecure,crossmnt,no_root_squash,fsid=0,no_subtree_check)
"/storages/nfs931" *(rw,insecure,crossmnt,no_root_squash,fsid=931,no_subtree_check)
"/storages/nfsn" *(rw,insecure,crossmnt,root_squash,no_subtree_check)
EOF

for i in nfs-mountd.service nfs-server.service; do
	systemctl enable ${i} 2>/dev/null ||true
	systemctl restart ${i}
done

