Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit e09d819

Browse files
tomwganemtonivdv
authored andcommitted
feature: add timeout argument to set timeout on docker-machine calls (#86)
1 parent ab8065c commit e09d819

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

docker-machine-nfs.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Options:
6060
-m, --mount-opts NFS mount options (default to 'noacl,async')
6161
-i, --use-ip-range Changes the nfs export ip to a range (e.g. -network 192.168.99.100 becomes -network 192.168.99)
6262
-p, --ip Configures the docker-machine to connect to your host machine via a specific ip address
63+
-t, --timeout Configures how long the timeout should be for docker-machine commands
6364
6465
Examples:
6566
@@ -137,7 +138,7 @@ setPropDefaults()
137138
prop_mount_options="noacl,async"
138139
prop_force_configuration_nfs=false
139140
prop_use_ip_range=false
140-
prop_use_ip=
141+
prop_timeout=
141142
}
142143

143144
# @info: Parses and validates the CLI arguments
@@ -183,6 +184,10 @@ parseCli()
183184
prop_use_ip="${i#*=}"
184185
;;
185186

187+
-t=*|--timeout=*)
188+
prop_timeout="-t ${i#*=}"
189+
;;
190+
186191
*)
187192
echoError "Unknown argument '$i' given"
188193
echo #EMPTY
@@ -220,7 +225,7 @@ checkMachinePresence ()
220225
{
221226
echoInfo "machine presence ... \t\t\t"
222227

223-
if [ "" = "$(docker-machine ls | sed 1d | grep -w "$1")" ]; then
228+
if [ "" = "$(docker-machine ls $2 | sed 1d | grep -w "$1")" ]; then
224229
echoError "Could not find the machine '$1'!"; exit 1;
225230
fi
226231

@@ -234,7 +239,7 @@ checkMachineRunning ()
234239
{
235240
echoInfo "machine running ... \t\t\t"
236241

237-
machine_state=$(docker-machine ls | sed 1d | grep "^$1\s" | awk '{print $4}')
242+
machine_state=$(docker-machine ls $2 | sed 1d | grep "^$1\s" | awk '{print $4}')
238243

239244
if [ "Running" != "${machine_state}" ]; then
240245
echoError "The machine '$1' is not running but '${machine_state}'!";
@@ -249,7 +254,7 @@ checkMachineRunning ()
249254
# @return: The driver used to create the machine
250255
getMachineDriver ()
251256
{
252-
docker-machine ls | sed 1d | grep "^$1\s" | awk '{print $3}'
257+
docker-machine ls $2 | sed 1d | grep "^$1\s" | awk '{print $3}'
253258
}
254259

255260
# @info: Loads mandatory properties from the docker machine
@@ -259,7 +264,7 @@ lookupMandatoryProperties ()
259264

260265
prop_machine_ip=$(docker-machine ip $1)
261266

262-
prop_machine_driver=$(getMachineDriver $1)
267+
prop_machine_driver=$(getMachineDriver $1 "$2")
263268

264269
if [ "$prop_machine_driver" = "vmwarefusion" ]; then
265270
prop_network_id="Shared"
@@ -504,10 +509,10 @@ setPropDefaults
504509

505510
parseCli "$@"
506511

507-
checkMachinePresence $prop_machine_name
508-
checkMachineRunning $prop_machine_name
512+
checkMachinePresence $prop_machine_name "$prop_timeout"
513+
checkMachineRunning $prop_machine_name "$prop_timeout"
509514

510-
lookupMandatoryProperties $prop_machine_name
515+
lookupMandatoryProperties $prop_machine_name "$prop_timeout"
511516

512517
if [ "$(isNFSMounted)" = "true" ] && [ "$prop_force_configuration_nfs" = false ]; then
513518
echoSuccess "\n NFS already mounted." ; showFinish ; exit 0

0 commit comments

Comments
 (0)