Class: VagrantPlugins::Bindfs::Action::Bind
- Inherits:
-
Object
- Object
- VagrantPlugins::Bindfs::Action::Bind
- Defined in:
- lib/vagrant-bindfs/bind.rb
Instance Method Summary collapse
- #bind_folders ⇒ Object
- #binded_folders ⇒ Object
- #call(env) ⇒ Object
- #handle_bindfs_installation ⇒ Object
-
#initialize(app, env, hook) ⇒ Bind
constructor
A new instance of Bind.
Constructor Details
#initialize(app, env, hook) ⇒ Bind
Returns a new instance of Bind.
7 8 9 10 11 |
# File 'lib/vagrant-bindfs/bind.rb', line 7 def initialize(app, env, hook) @app = app @env = env @hook = hook end |
Instance Method Details
#bind_folders ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vagrant-bindfs/bind.rb', line 34 def bind_folders @env[:ui].info I18n.t("vagrant.config.bindfs.status.binding_all") binded_folders.each do |id, | command = VagrantPlugins::Bindfs::Command.new(@env, ) unless @machine.communicate.test("test -d #{command.source}") @env[:ui].error I18n.t( "vagrant.config.bindfs.errors.source_path_not_exist", path: command.source ) next end unless [:skip_verify_user] == true || command.user.nil? || @machine.communicate.test("getent passwd #{command.user.shellescape}") @env[:ui].error I18n.t( "vagrant.config.bindfs.errors.user_not_exist", user: command.user ) next end unless [:skip_verify_user] == true || command.group.nil? || @machine.communicate.test("getent group #{command.group.shellescape}") @env[:ui].error I18n.t( "vagrant.config.bindfs.errors.group_not_exist", group: command.group ) next end if @machine.communicate.test("mount | grep '^bindfs' | grep #{command.destination}") @env[:ui].info I18n.t( "vagrant.config.bindfs.already_mounted", dest: command.destination ) next end @env[:ui].info I18n.t( "vagrant.config.bindfs.status.binding_entry", dest: command.destination, source: command.source ) @machine.communicate.tap do |comm| comm.sudo("mkdir -p #{command.destination}") comm.sudo(command.build, error_class: Error, error_key: :binding_failed) @env[:ui].info(command.build) if @machine.config.bindfs.debug end end end |
#binded_folders ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-bindfs/bind.rb', line 25 def binded_folders @binded_folders ||= begin @machine.config.bindfs.bind_folders.reduce({}) do |binded, (name, )| binded[name] = if [:hook] == @hook binded end end end |
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant-bindfs/bind.rb', line 13 def call(env) @app.call(env) @env = env @machine = env[:machine] unless binded_folders.empty? handle_bindfs_installation bind_folders end end |
#handle_bindfs_installation ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/vagrant-bindfs/bind.rb', line 87 def handle_bindfs_installation unless @machine.guest.capability(:bindfs_installed) @env[:ui].warn(I18n.t("vagrant.config.bindfs.not_installed")) unless @machine.guest.capability(:install_bindfs) raise Vagrant::Bindfs::Error, :cannot_install end end unless @machine.guest.capability(:fuse_loaded) @env[:ui].warn(I18n.t("vagrant.config.bindfs.not_loaded")) unless @machine.guest.capability(:enable_fuse) raise Vagrant::Bindfs::Error, :cannot_enable_fuse end end end |