-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows_ddev_nfs_setup.sh
executable file
·59 lines (48 loc) · 1.95 KB
/
windows_ddev_nfs_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# Set up NFS on Windows for ddev.
set -o errexit
set -o pipefail
set -o nounset
# Currently Windows ddev containers run as UID 1000
# We want the NFS mount to do the same.
DDEV_WINDOWS_UID=1000
DDEV_WINDOWS_GID=1000
nfs_addr=127.0.0.1
mkdir -p ~/.ddev
docker run --rm -t -v "/$HOME/.ddev:/tmp/junker99" busybox:stable ls //tmp/junker99 >/dev/null || ( echo "Docker does not seem to be running or functional, please check it for problems" && exit 101)
status=uninstalled
if nssm status nfsd 2>/dev/null ; then
status=$(nssm status nfsd)
fi
if [ "$status" = "SERVICE_RUNNING" ] ; then
echo "nfsd is already running. You can configure its behavior with 'nssm edit nfsd'."
exit 0
fi
if [ "$status" = "SERVICE_STOPPED" ] ; then
echo "nfsd was already installed, starting it. You can configure its behavior with 'nssm edit nfsd'"
sudo nssm start nfsd
exit 0
fi
if ! command -v winnfsd.exe >/dev/null; then
echo "winnfsd.exe does not seem to be installed or is not in the PATH"
exit 102
fi
winnfsd=$(command -v winnfsd.exe)
if [ -f "$HOME/.ddev/nfs_exports.txt" ]; then
printf "$HOME/.ddev/nfs_exports.txt already exists, not overwriting it, you will be responsible for its exports.\n"
else
echo "
# Exports for winnfsd for ddev
# You can edit these yourself to match your workflow
# But nfs must share your project directory
# Additional lines can be added for additional directories or drives.
${HOMEDRIVE}${HOMEPATH} > ${HOME}" >"$HOME/.ddev/nfs_exports.txt"
fi
sudo nssm install nfsd "${winnfsd}" -id ${DDEV_WINDOWS_UID} ${DDEV_WINDOWS_GID} -addr $nfs_addr -log off -pathFile "\"$HOMEDRIVE$HOMEPATH\.ddev\nfs_exports.txt\""
sudo nssm start nfsd || true
sleep 2
nssm status nfsd
echo "winnfsd has been installed as service nfsd serving the mounts in ~/.ddev/nfs_exports.txt"
echo "You can edit that file and restart the nfsd service"
echo "with 'sudo nssm restart nfsd'"
echo "Or you can edit its behavior with 'sudo nssm edit nfsd'"