Files
init.sh/modules/conf_nfs.sh

52 lines
1.6 KiB
Bash

# ------------------------------------------------------------------------------
# Description of module conf_nfs
# Copyright (c) Year Your Name <your.mail@host.tld>
# ------------------------------------------------------------------------------
# <Licence header compatible with BSD-3 licence, you want to use>
# ------------------------------------------------------------------------------
# Variable list:
# * <VARNAME>: role explaination
# ------------------------------------------------------------------------------
# Module version
export VER_conf_nfs="0.0.1"
# Module's code
conf_nfs()
{
pkginst nfs-common
for mnt in $NFS_MOUNTS; do
if [[ ! $(grep "$(eval echo \$MOUNTSERV_$mnt)/d" /etc/fstab) ]]; then
echo -e "$(eval echo \$MOUNTSERV_$mnt)\t$(eval echo \$MOUNTPOINT_$mnt)\tnfs4\tdefaults,_netdev\t0\t0" >> /etc/fstab
fi
if [[ ! -d $(eval echo \$MOUNTPOINT_$mnt) ]]; then
mkdir -pv $(eval echo \$MOUNTPOINT_$mnt)
fi
mount $(eval echo \$MOUNTPOINT_$mnt)
done
}
# Preliminary checks code for the module
precheck_conf_nfs()
{
if [[ -n $NFS_MOUNTS ]]; then
for mnt in $NFS_MOUNTS; do
if [[ -z $(eval echo \$MOUNTSERV_$mnt) ]]; then
prnt E "The server mount for $NFS_MOUNT is not declared."
die 182
fi
if [[ -z $(eval echo \$MOUNTPOINT_$mnt) ]]; then
prnt E "The mountpoint for $NFS_MOUNT is not declared."
die 183
fi
prnt I "NFS server $(eval echo \$MOUNTSERV_$mnt) will be mounted on $(eval echo \$MOUNTPOINT_$mnt)."
done
fi
}
# Public functions might be exported
export -f conf_nfs
export -f precheck_conf_nfs
# EOF