11#! /usr/bin/env bash
2+ VERSION=2.0.0
23set -o errexit -o errtrace -o noclobber -o nounset -o pipefail
34IFS=$' \n\t '
45
104105 fi
105106}
106107
108+ function enableNFS {
109+ echo " Setting up NFS..."
110+ U=` id -u`
111+ G=` id -g`
112+
113+ LINE=" /System/Volumes/Data/Users -alldirs -mapall=$U :$G localhost"
114+ FILE=/etc/exports
115+ sudo touch $FILE
116+ grep -qF -- " $LINE " " $FILE " || sudo echo " $LINE " | sudo tee -a $FILE > /dev/null
117+
118+ LINE=" nfs.server.mount.require_resv_port = 0"
119+ FILE=/etc/nfs.conf
120+ grep -qF -- " $LINE " " $FILE " || sudo echo " $LINE " | sudo tee -a $FILE > /dev/null
121+
122+ echo " Restarting nfsd..."
123+ sudo nfsd restart
124+
125+ echo " You should restart docker to ensure NFS mounts works..."
126+ }
127+
107128bold=$( tput bold)
108129normal=$( tput sgr0)
109130
@@ -125,6 +146,9 @@ Commands:
125146 container. Otherwise, the drush container is used to
126147 run the command.
127148
149+ nfs:enable
150+ Enable support for NFS shares (performance boost on Macs)
151+
128152 sync
129153 Sync both database and files.
130154
@@ -196,6 +220,9 @@ Commands:
196220 down
197221 Stop and remove containers, networks, images, and volumes
198222
223+ version
224+ Display this tool's current version
225+
199226 *
200227 Pass command and arguments to `docker-compose` and
201228 hope for the best.
@@ -239,6 +266,24 @@ if [[ "$#" -gt "0" && "$1" == "template:install" ]]; then
239266 exit
240267fi
241268
269+ # Allow nfs:enable without existence of docker-compose.yml.
270+ if [[ " $# " -gt " 0" && " $1 " == " nfs:enable" ]]; then
271+ enableNFS
272+ exit
273+ fi
274+
275+ # Allow version without existence of docker-compose.yml.
276+ if [[ " $# " -gt " 0" && " $1 " == " version" ]]; then
277+ echo Version: ${VERSION}
278+ exit
279+ fi
280+
281+ # Allow help without existence of docker-compose.yml.
282+ if [[ " $# " -gt " 0" && " $1 " == " --help" ]]; then
283+ usage
284+ exit
285+ fi
286+
242287# @see https://unix.stackexchange.com/questions/13464/is-there-a-way-to-find-a-file-in-an-inverse-recursive-search/13474
243288upsearch () {
244289 slashes=${PWD// [^\/]/ }
551596 docker_compose exec " $@ " /usr/bin/env sh
552597 ;;
553598
554- --help)
555- usage
556- exit
557- ;;
558-
559599 * )
560600 docker_compose " $cmd " " $@ "
561601 ;;
0 commit comments