Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexandru Croitor
minicoin
Commits
2d652b04
Commit
2d652b04
authored
Mar 02, 2022
by
Volker Hilsheimer
Browse files
Refactor shared folder handling a bit
Disabling is still messy.
parent
65321806
Changes
2
Hide whitespace changes
Inline
Side-by-side
minicoin/Vagrantfile
View file @
2d652b04
...
...
@@ -255,29 +255,7 @@ Vagrant.configure("2") do |config|
end
# folder sharing, taking guest OS and provider specific quirks into account
shares
=
machine
[
"shared_folders"
]
unless
shares
.
nil?
if
shares
.
include?
(
"disabled"
)
box
.
vm
.
synced_folder
"."
,
"/opt/minicoin"
,
disabled:
true
if
box
.
vm
.
guest
==
:windows
box
.
vm
.
provision
"minicoin guest scripts:upload"
,
type: :file
,
source:
"./util"
,
destination:
"C:
\\
opt
\\
minicoin
\\
"
else
box
.
vm
.
provision
"minicoin guest scripts:script"
,
type: :shell
,
inline:
"sudo mkdir -p /opt/minicoin/util; chown -R vagrant /opt/minicoin"
,
upload_path:
"/tmp/vagrant-shell_minicoin_guest_scripts"
box
.
vm
.
provision
"minicoin guest scripts:upload"
,
type: :file
,
source:
"./util"
,
destination:
"/opt/minicoin/"
end
else
share_folders
(
box
,
machine
,
shares
)
end
end
share_folders
(
box
,
machine
,
machine
[
"shared_folders"
])
# Definition of provisioning steps
roles
=
machine
[
"roles"
]
||
[]
...
...
minicoin/lib/sharing.rb
View file @
2d652b04
...
...
@@ -73,6 +73,8 @@ def mutagen_share(box, role_params, machine)
end
def
share_folders
(
box
,
machine
,
shares
)
return
if
shares
.
nil?
shares
=
Marshal
.
load
(
Marshal
.
dump
(
shares
))
raise
"shared_folders needs to be a list of mappings"
if
!
shares
.
is_a?
(
Array
)
default_shares
=
{}
...
...
@@ -81,6 +83,7 @@ def share_folders(box, machine, shares)
share_type
=
share
[
"type"
]
share
.
delete
(
"type"
)
share
=
share
[
"paths"
]
if
share
[
"paths"
]
share
=
[
share
]
unless
share
.
respond_to?
(
:each
)
share
.
each
do
|
host
,
guest
|
# each entry could be just alpha; or alpha => beta or host => alpha; guest => beta
guest
||=
host
...
...
@@ -110,6 +113,27 @@ def share_folders(box, machine, shares)
end
end
# if default folder sharing is disabled, then upload the needed guest-side scripts
if
shares
.
include?
(
"disabled"
)
box
.
vm
.
synced_folder
"."
,
"/opt/minicoin"
,
disabled:
true
if
box
.
vm
.
guest
==
:windows
box
.
vm
.
provision
"minicoin guest scripts:upload"
,
type: :file
,
source:
"./util"
,
destination:
"C:
\\
opt
\\
minicoin
\\
"
else
box
.
vm
.
provision
"minicoin guest scripts:script"
,
type: :shell
,
inline:
"sudo mkdir -p /opt/minicoin/util; chown -R vagrant /opt/minicoin"
,
upload_path:
"/tmp/vagrant-shell_minicoin_guest_scripts"
box
.
vm
.
provision
"minicoin guest scripts:upload"
,
type: :file
,
source:
"./util"
,
destination:
"/opt/minicoin/"
end
return
end
# set up default shares, take care of resulting network drives on guests
win_links
=
{}
default_shares
.
each
do
|
host
,
guest
|
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment