Difference between
modified post 08b12c by Anonymous on Mon 11th Sep 2023 12:22
original post 0d2 by Anonymous on Tue 5th Sep 2023 11:49
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/bin/bash | |
| 2 | 2 | ||
| 3 | 3 | # | |
| 4 | 4 | # msnfs41client.bash - simple Cygwin frontent for the msnfsv41 | |
| 5 | 5 | # NFSv4.1 filesystem driver | |
| 6 | 6 | # | |
| 7 | 7 | ||
| 8 | 8 | # | |
| 9 | 9 | # Written by Roland Mainz <roland.mainz@nrubsig.org> | |
| 10 | 10 | # | |
| 11 | 11 | ||
| 12 | 12 | function nfsclient_install | |
| 13 | 13 | { | |
| 14 | 14 | set -o nounset | |
| 15 | 15 | set -o xtrace | |
| 16 | 16 | set -o errexit | |
| 17 | 17 | ||
| 18 | 18 | # | |
| 19 | 19 | # Test whether we have the Windows permissions to install DLLs | |
| 20 | 20 | # and the kernel module | |
| 21 | 21 | # | |
| 22 | 22 | if ! [[ "$(id -G)" =~ (^|[[:space:]]+)544([[:space:]]+|$) ]] ; then | |
| 23 | 23 | printf $"%s: Install requires Windows Adminstator permissions.\n" "$0" | |
| 24 | 24 | return 1 | |
| 25 | 25 | fi | |
| 26 | 26 | ||
| 27 | 27 | # make sure all binaries are executable, Windows cmd does | |
| 28 | 28 | # not care, but Cygwin&bash do. | |
| 29 | 29 | # If *.ddl are not executable nfs*.exe fail with 0xc0000022 | |
| 30 | 30 | chmod a+x *.exe *.dll | |
| 31 | 31 | ||
| 32 | 32 | if false ; then | |
| 33 | 33 | # install.bat needs PATH to include $PWD | |
| 34 | 34 | PATH="$PWD:$PATH" cmd /c install.bat | |
| 35 | 35 | else | |
| 36 | 36 | nfs_install | |
| 37 | 37 | rundll32 setupapi.dll,InstallHinfSection DefaultInstall 132 ./nfs41rdr.inf | |
| 38 | 38 | fi | |
| 39 | 39 | ||
| 40 | 40 | cp etc_netconfig /cygdrive/c/etc/netconfig | |
| 41 | 41 | cp ms-nfs41-idmap.conf /cygdrive/c/etc/. | |
| 42 | 42 | ||
| 43 | 43 | bcdedit /set testsigning on | |
| 44 | 44 | regtool -s set '/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/Domain' 'GLOBAL.LOC' | |
| 45 | 45 | ||
| 46 | 46 | sc query Dfsc | |
| 47 | 47 | sc stop Dfsc || true | |
| 48 | 48 | sc config Dfsc start=disabled | |
| 49 | 49 | ||
| 50 | 50 | sc query nfs41_driver | |
| 51 | 51 | domainname | |
| 52 | 52 | ||
| 53 | 53 | return 0 | |
| 54 | 54 | } | |
| 55 | 55 | ||
| 56 | 56 | function nfsclient_rundeamon | |
| 57 | 57 | { | |
| 58 | 58 | set -o xtrace | |
| 59 | 59 | set -o nounset | |
| 60 | 60 | set -o errexit | |
| 61 | 61 | ||
| 62 | 62 | nfsd_debug -d 0 --noldap --gid 1616 --uid 1616 | |
| 63 | 63 | return $? | |
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | 66 | function nfsclient_mount_homedir | |
| 67 | 67 | { | |
| 68 | 68 | set -o xtrace | |
| 69 | 69 | set -o nounset | |
| 70 | 70 | ||
| 71 | 71 | nfs_mount -p -o sec=sys H 'derfwpc5131:/export/home/rmainz' | |
| 72 | + | mkdir -p /home/rmainz | |
| 72 | 73 | mount -o bind,posix=1 /cygdrive/h /home/rmainz | |
| 73 | 74 | return $? | |
| 74 | 75 | } | |
| 75 | 76 | ||
| 76 | 77 | function nfsclient_umount_homedir | |
| 77 | 78 | { | |
| 78 | 79 | set -o xtrace | |
| 79 | 80 | set -o nounset | |
| 80 | 81 | ||
| 81 | 82 | nfs_mount -d H | |
| 83 | + | # remove bind mount | |
| 82 | 86 | return $? | |
| 83 | 87 | } | |
| 84 | 88 | ||
| 85 | 89 | function main | |
| 86 | 90 | { | |
| 87 | 91 | typeset cmd="$1" | |
| 88 | 92 | ||
| 89 | 93 | export PATH="$PWD:$PATH" | |
| 90 | 94 | ||
| 91 | 95 | if ! which 'nfsd.exe' >/dev/null 2>&1 ; then | |
| 92 | 96 | printf $"%s: nfsd not found in %q\n" "$0" "$PWD" 1>&2 | |
| 93 | 97 | return 1 | |
| 94 | 98 | fi | |
| 95 | 99 | if ! which 'nfs_mount.exe' >/dev/null 2>&1 ; then | |
| 96 | 100 | printf $"%s: nfs_mount not found in %q\n" "$0" "$PWD" 1>&2 | |
| 97 | 101 | return 1 | |
| 98 | 102 | fi | |
| 99 | 103 | ||
| 100 | 104 | case "$cmd" in | |
| 101 | 105 | 'install') | |
| 102 | 106 | nfsclient_install | |
| 103 | 107 | return $? | |
| 104 | 108 | ;; | |
| 105 | 109 | 'run_deamon' | 'run_daemon') | |
| 106 | 110 | nfsclient_rundeamon | |
| 107 | 111 | return $? | |
| 108 | 112 | ;; | |
| 109 | 113 | 'mount_homedir') | |
| 110 | 114 | nfsclient_mount_homedir | |
| 111 | 115 | return $? | |
| 112 | 116 | ;; | |
| 113 | 117 | 'umount_homedir') | |
| 114 | 118 | nfsclient_umount_homedir | |
| 115 | 119 | return $? | |
| 116 | 120 | ;; | |
| 117 | 121 | *) | |
| 118 | 122 | printf $"%s: Unknown cmd %q\n" "$0" "$cmd" 1>&2 | |
| 119 | 123 | return 1 | |
| 120 | 124 | ;; | |
| 121 | 125 | esac | |
| 122 | 126 | return 1 | |
| 123 | 127 | } | |
| 124 | 128 | ||
| 125 | 129 | main "$@" | |
| 126 | 130 | exit $? | |
| 127 | 131 | ||
| 128 | 132 | # EOF. | |
| 129 | 133 |
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.
rovema.kpaste.net RSS