Skip to content

Commit

Permalink
add ip-range feature (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonivdv authored Oct 19, 2016
1 parent 7d080eb commit a48f3a5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docker-machine-nfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Options:
-n, --nfs-config NFS configuration to use in /etc/exports. (default to '-alldirs -mapall=\$(id -u):\$(id -g)')
-s, --shared-folder,... Folder to share (default to /Users)
-m, --mount-opts NFS mount options (default to 'noacl,async')
-i, --use-ip-range Changes the nfs export ip to a range (e.g. -network 192.168.99.100 becomes -network 192.168.99)
Examples:
Expand All @@ -76,7 +77,6 @@ Examples:
$ docker-machine-nfs test --mount-opts="noacl,async,nolock,vers=3,udp,noatime,actimeo=1"
> Configure the /User folder with NFS and specific mount options.
EOF
exit 0
}
Expand Down Expand Up @@ -131,6 +131,7 @@ setPropDefaults()
prop_nfs_config="-alldirs -mapall="$(id -u):$(id -g)
prop_mount_options="noacl,async"
prop_force_configuration_nfs=false
prop_use_ip_range=false
}

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


-f|--force)
prop_force_configuration_nfs=true
shift
;;

-i|--use-ip-range)
prop_use_ip_range=true
;;

*)
Expand Down Expand Up @@ -343,10 +346,15 @@ configureNFS()
# Write new exports blocks beginning
exports="${exports}\n${exports_begin}\n"

local machine_ip=$prop_machine_ip
if [ "$prop_use_ip_range" = true ]; then
machine_ip="${machine_ip%.*}"
fi

for shared_folder in "${prop_shared_folders[@]}"
do
# Add new exports
exports="${exports}$shared_folder $prop_machine_ip $prop_nfs_config\n"
exports="${exports}$shared_folder -network $machine_ip $prop_nfs_config\n"
done

# Write new exports block ending
Expand Down

0 comments on commit a48f3a5

Please sign in to comment.