Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow crossmounts and use subnet mask examples for readme #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Adding `-e READ_ONLY=true` will cause the exports file to contain `ro` instead o

Adding `-e SYNC=true` will cause the exports file to contain `sync` instead of `async`, enabling synchronous mode. Check the exports man page for more information: https://linux.die.net/man/5/exports.

Adding `-e PERMITTED="10.11.99.*"` will permit only hosts with an IP address starting 10.11.99 to mount the file share.
Adding `-e PERMITTED="10.11.99.0\/24"` will permit only hosts with an IP address starting 10.11.99 to mount the file share. The single backslash is used for escaping the slash dividing net address and netmask during the replacement via sed.

Adding `-e CROSSMNT=yes` will allow to share mounts which are placed in `/some/where/fileshare`. This is especially needed when allowing more than only one IP.

Due to the `fsid=0` parameter set in the **/etc/exports file**, there's no need to specify the folder name when mounting from a client. For example, this works fine even though the folder being mounted and shared is /nfsshare:

Expand Down
2 changes: 1 addition & 1 deletion exports
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{SHARED_DIRECTORY}} {{PERMITTED}}({{READ_ONLY}},fsid=0,{{SYNC}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)
{{SHARED_DIRECTORY}} {{PERMITTED}}({{READ_ONLY}},fsid=0,{{SYNC}},{{CROSSMNT}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)
10 changes: 10 additions & 0 deletions nfsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ else
/bin/sed -i "s/{{SYNC}}/sync/g" /etc/exports
fi

# Check if the CROSSMNT variable is set (rather than a null string) using parameter expansion
if [ -z "${CROSSMNT+y}" ]; then
echo "The CROSSMNT environment variable is unset or null, so do not allow crossmounts."
echo "Mounts in shares will appear empty"
/bin/sed -i "s/{{CROSSMNT}},//g" /etc/exports
else
echo "The CROSSMNT environment variable is set, allowing crossmounts."
/bin/sed -i "s/{{CROSSMNT}}/crossmnt/g" /etc/exports
fi

# Partially set 'unofficial Bash Strict Mode' as described here: http://redsymbol.net/articles/unofficial-bash-strict-mode/
# We don't set -e because the pidof command returns an exit code of 1 when the specified process is not found
# We expect this at times and don't want the script to be terminated when it occurs
Expand Down