- #!/bin/bash
- #
- # msnfs41client.bash - simple Cygwin frontent for the msnfsv41
- # NFSv4.1 filesystem driver
- #
- #
- # Written by Roland Mainz <roland.mainz@nrubsig.org>
- #
- #
- # Examples:
- #
- # 2. Mount for all users:
- # (requires PsExec from https://download.sysinternals.com/files/PSTools.zip
- # in /home/roland_mainz/work/win_pstools/)
- # Shell1: cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && /home/roland_mainz/work/win_pstools/PsExec -s -w $(cygpath -w "$PWD") $(cygpath -w /usr/bin/bash) "$PWD/../msnfs41client.bash" run_deamon
- # Shell2: (cd /cygdrive/c/Users/roland_mainz/Downloads/ms-nfs41-client-x64/ms-nfs41-client-x64 && /home/roland_mainz/work/win_pstools/PsExec -s -w $(cygpath -w "$PWD") $(cygpath -w /usr/bin/bash) "$PWD/../msnfs41client.bash" mount_homedir)
- #
- function nfsclient_install
- {
- set -o nounset
- set -o xtrace
- set -o errexit
- #
- # Test whether we have the Windows permissions to install DLLs
- # and the kernel module
- #
- # Usually Windows Adminstrator rights are indicated by the
- # membership in group "544(Administratoren)" (Cygwin maps
- # "SID S-1-5-32-544" to GID 544)
- #
- if ! [[ "$(id -G)" =~ (^|[[:space:]]+)544([[:space:]]+|$) ]] ; then
- printf $"%s: Install requires Windows Adminstator permissions.\n" "$0"
- return 1
- fi
- # make sure all binaries are executable, Windows cmd does
- # not care, but Cygwin&bash do.
- # If *.ddl are not executable nfs*.exe fail with 0xc0000022
- chmod a+x *.exe *.dll
- if false ; then
- # install.bat needs PATH to include $PWD
- PATH="$PWD:$PATH" cmd /c install.bat
- else
- nfs_install
- rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf
- fi
- cp etc_netconfig /cygdrive/c/etc/netconfig
- cp ms-nfs41-idmap.conf /cygdrive/c/etc/.
- bcdedit /set testsigning on
- regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC'
- sc query Dfsc
- sc stop Dfsc || true
- sc config Dfsc start=disabled
- sc query nfs41_driver
- domainname
- # check whether the driver really has been installed
- md5sum \
- "$PWD/nfs41_driver.sys" \
- /cygdrive/c/Windows/System32/drivers/nfs41_driver.sys
- return 0
- }
- function nfsclient_rundeamon
- {
- set -o xtrace
- set -o nounset
- nfsd_debug -d 2 --noldap --gid 1616 --uid 1616
- return $?
- }
- function nfsclient_mount_homedir
- {
- set -o xtrace
- set -o nounset
- set -o errexit
- nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home/rmainz'
- mkdir -p /home/rmainz
- mount -o bind,posix=1 /cygdrive/h /home/rmainz
- return $?
- }
- function nfsclient_umount_homedir
- {
- set -o xtrace
- set -o nounset
- typeset -i res
- nfs_mount -d H
- (( res=$? ))
- if (( res == 0 )) ; then
- # remove bind mount
- umount /home/rmainz
- fi
- return $res
- }
- function main
- {
- typeset cmd="$1"
- # "$PATH:/usr/bin:/bin" is used for PsExec where $PATH might be empty
- export PATH="$PWD:$PATH:/usr/bin:/bin"
- if [[ "$cmd" != 'install' ]] ; then
- if ! which 'nfsd.exe' >/dev/null 2>&1 ; then
- printf $"%s: nfsd not found in %q\n" "$0" "$PWD" 1>&2
- return 1
- fi
- if ! which 'nfs_mount.exe' >/dev/null 2>&1 ; then
- printf $"%s: nfs_mount not found in %q\n" "$0" "$PWD" 1>&2
- return 1
- fi
- fi
- case "$cmd" in
- 'install')
- nfsclient_install
- return $?
- ;;
- 'run_deamon' | 'run_daemon')
- nfsclient_rundeamon
- return $?
- ;;
- 'mount_homedir')
- nfsclient_mount_homedir
- return $?
- ;;
- 'umount_homedir')
- nfsclient_umount_homedir
- return $?
- ;;
- *)
- printf $"%s: Unknown cmd %q\n" "$0" "$cmd" 1>&2
- return 1
- ;;
- esac
- return 1
- }
- main "$@"
- exit $?
- # EOF.
msnfs41client.bash - simple Cygwin frontent for the msnfsv41 NFSv4.1 filesystem driver
Posted by Anonymous on Fri 15th Sep 2023 14:47
raw | new post
view followups (newest first): msnfs41client.bash - simple Cygwin frontent for the msnfsv41 NFSv4.1 filesystem driver by Anonymous
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.