rules/filesystem/fs/etc/rc.d: add nfs config files for server/cliente.

This commit is contained in:
Pedro Gonçalves 2019-04-17 15:24:34 +01:00
parent 9824634051
commit ae1b66aafc
2 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,45 @@
mount_path()
{
rpath="$cfg_storage_host:$1"
lpath="$1"
mkdir -p "$lpath"
mount -t nfs -o wsize=32768 "$rpath" "$lpath"
if [ $? -eq 0 ]; then
echo "* Mounted '$rpath' in '$lpath'"
return 0
fi
return 1
}
start()
{
/usr/bin/rpcbind
if [ $? -ne 0 ]; then
echo "ERROR: failed to start rpcbind."
return 1
fi
for path in $cfg_storage_paths; do
n=0; while [ $n -lt "$cfg_storage_timeout" ]; do
mount_path "$path"
if [ $? -eq 0 ]; then
break
fi
let n++
sleep 1
done
done
}
stop()
{
killall rpcbind
for path in $cfg_storage_paths; do
umount "$path"
done
}

View File

@ -0,0 +1,76 @@
start_nfs_server()
{
echo "* Creating NFS administrative folder..."
mkdir -p /var/lib/nfs
if ! [ -d /var/lib/nfs ]; then
echo "ERROR: failed to create data folder."
return 1
fi
echo "* Launching rpcbind..."
/usr/bin/rpcbind
if [ $? -ne 0 ]; then
echo "ERROR: failed to start rpcbind."
return 1
fi
echo "* Launching rpc.statd..."
/usr/bin/rpc.statd
if [ $? -ne 0 ]; then
echo "ERROR: failed to start rpc.statd."
return 1
fi
echo "* Launching rpc.nfsd..."
/usr/bin/rpc.nfsd
if [ $? -ne 0 ]; then
echo "ERROR: failed to start rpc.nfsd."
return 1
fi
echo "* Creating NFS filesystem table..."
/usr/bin/exportfs -ra
if [ $? -ne 0 ]; then
echo "ERROR: failed to create filesystem table."
return 1
fi
echo "* Launching rpc.mountd..."
/usr/bin/rpc.mountd
if [ $? -ne 0 ]; then
echo "ERROR: failed to start rpc.mountd."
return 1
fi
echo "* Exporting NFS filesystems..."
/usr/bin/exportfs \
-o rw,async,no_root_squash,no_subtree_check \
10.0.0.0/16:"$cfg_storage_dir"
if [ $? -ne 0 ]; then
echo "ERROR: failed to export filesystems."
return 1
fi
}
stop_nfs_server()
{
echo "* Unexporting NFS filesystems..."
exportfs -au 2> /dev/null
echo "* Terminating rpc.mountd..."
killall rpc.mountd 2> /dev/null
echo "* Terminating rpc.statd..."
killall rpc.statd 2> /dev/null
echo "* Terminating rpc.bind..."
killall rpcbind 2> /dev/null
}
start()
{
mkdir -p "$cfg_storage_dir"
start_nfs_server
}
stop()
{
stop_nfs_server
}