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

Add more flexible options #23

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
add SHARED_DIRECTORY for backwards compatibility
colearendt committed Nov 12, 2018
commit 4ea2c34161d11688bbe2822c0314be846e99295e
31 changes: 8 additions & 23 deletions nfsd.sh
Original file line number Diff line number Diff line change
@@ -68,7 +68,14 @@ else
opts=${NFS_OPTS}
fi;


# Check if the SHARED_DIRECTORY variable is empty
if [ -z "${SHARED_DIRECTORY}" ]; then
echo "The SHARED_DIRECTORY environment variable is unset or null, using new approach"
else
echo "SHARED_DIRECTORY is set. Please use CMD instead"
echo "Adding SHARED_DIRECTORY to CMD input"
mounts[${#mounts[@]}]=$SHARED_DIRECTORY
fi

# Get mounts
mounts="${@}"
@@ -79,28 +86,6 @@ for mnt in "${mounts[@]}"; do
echo "$src ${PERMITTED}($opts)" >> /etc/exports
done

## Check if the SHARED_DIRECTORY variable is empty
#if [ -z "${SHARED_DIRECTORY}" ]; then
# echo "The SHARED_DIRECTORY environment variable is unset or null, exiting..."
# exit 1
#else
# echo "Writing SHARED_DIRECTORY to /etc/exports file"
# /bin/sed -i "s@{{SHARED_DIRECTORY}}@${SHARED_DIRECTORY}@g" /etc/exports
#fi
#
## This is here to demonsrate how multiple directories can be shared. You
## would need a block like this for each extra share.
## Any additional shares MUST be subdirectories of the root directory specified
## by SHARED_DIRECTORY.
#
## Check if the SHARED_DIRECTORY_2 variable is empty
#if [ ! -z "${SHARED_DIRECTORY_2}" ]; then
# echo "Writing SHARED_DIRECTORY_2 to /etc/exports file"
# echo "{{SHARED_DIRECTORY_2}} {{PERMITTED}}({{READ_ONLY}},{{SYNC}},no_subtree_check,no_auth_nlm,insecure,no_root_squash)" >> /etc/exports
# /bin/sed -i "s@{{SHARED_DIRECTORY_2}}@${SHARED_DIRECTORY_2}@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 if it occurs