Sha256: c11e7d617a9d26a964fa694c8205a74165ec070a5d16d71a342c1addbce161ee

Contents?: true

Size: 1.45 KB

Versions: 22

Compression:

Stored size: 1.45 KB

Contents

require "pathname"

module VagrantPlugins
  module HostRedHat
    module Cap
      class NFS
        def self.nfs_check_command(env)
          "#{nfs_server_binary} status"
        end

        def self.nfs_start_command(env)
          "#{nfs_server_binary} start"
        end

        protected

        def self.nfs_server_binary
          nfs_server_binary = "/etc/init.d/nfs"

          # On Fedora 16+, systemd replaced init.d, so we have to use the
          # proper NFS binary. This checks to see if we need to do that.
          release_file = Pathname.new("/etc/redhat-release")
          begin
            release_file.open("r:ISO-8859-1:UTF-8") do |f|
              match = /(Red Hat|CentOS|Fedora).* release ([0-9]+)/.match(f.gets)
              if match
                distribution = match[1]
                version_number = match[2].to_i
                if (distribution =~ /Fedora/ && version_number >= 16) ||
                   (distribution =~ /Red Hat|CentOS/ && version_number >= 7)
                  # "service nfs-server" will redirect properly to systemctl
                  # when "service nfs-server restart" is called.
                  nfs_server_binary = "/usr/sbin/service nfs-server"
                end
              end
            end
          rescue Errno::ENOENT
            # File doesn't exist, not a big deal, assume we're on a
            # lower version.
          end

          nfs_server_binary
        end
      end
    end
  end
end

Version data entries

22 entries across 19 versions & 4 rubygems

Version Path
vagrant-unbundled-1.9.8.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.9.7.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/hosts/redhat/cap/nfs.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/hosts/redhat/cap/nfs.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/hosts/redhat/cap/nfs.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.9.5.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.9.1.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/hosts/redhat/cap/nfs.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/hosts/redhat/cap/nfs.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/hosts/redhat/cap/nfs.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.5.2 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.5.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.4.2 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.4.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.1.2 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-1.8.1.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/hosts/redhat/cap/nfs.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/hosts/redhat/cap/nfs.rb