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

Commit a48f3a5

Browse files
authored
add ip-range feature (#63)
1 parent 7d080eb commit a48f3a5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docker-machine-nfs.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Options:
5858
-n, --nfs-config NFS configuration to use in /etc/exports. (default to '-alldirs -mapall=\$(id -u):\$(id -g)')
5959
-s, --shared-folder,... Folder to share (default to /Users)
6060
-m, --mount-opts NFS mount options (default to 'noacl,async')
61+
-i, --use-ip-range Changes the nfs export ip to a range (e.g. -network 192.168.99.100 becomes -network 192.168.99)
6162
6263
Examples:
6364
@@ -76,7 +77,6 @@ Examples:
7677
$ docker-machine-nfs test --mount-opts="noacl,async,nolock,vers=3,udp,noatime,actimeo=1"
7778
7879
> Configure the /User folder with NFS and specific mount options.
79-
8080
EOF
8181
exit 0
8282
}
@@ -131,6 +131,7 @@ setPropDefaults()
131131
prop_nfs_config="-alldirs -mapall="$(id -u):$(id -g)
132132
prop_mount_options="noacl,async"
133133
prop_force_configuration_nfs=false
134+
prop_use_ip_range=false
134135
}
135136

136137
# @info: Parses and validates the CLI arguments
@@ -164,10 +165,12 @@ parseCli()
164165
prop_mount_options="${i#*=}"
165166
;;
166167

167-
168168
-f|--force)
169169
prop_force_configuration_nfs=true
170-
shift
170+
;;
171+
172+
-i|--use-ip-range)
173+
prop_use_ip_range=true
171174
;;
172175

173176
*)
@@ -343,10 +346,15 @@ configureNFS()
343346
# Write new exports blocks beginning
344347
exports="${exports}\n${exports_begin}\n"
345348

349+
local machine_ip=$prop_machine_ip
350+
if [ "$prop_use_ip_range" = true ]; then
351+
machine_ip="${machine_ip%.*}"
352+
fi
353+
346354
for shared_folder in "${prop_shared_folders[@]}"
347355
do
348356
# Add new exports
349-
exports="${exports}$shared_folder $prop_machine_ip $prop_nfs_config\n"
357+
exports="${exports}$shared_folder -network $machine_ip $prop_nfs_config\n"
350358
done
351359

352360
# Write new exports block ending

0 commit comments

Comments
 (0)