Sha256: d60a0b88cf3a080927ec23e6010b2a4a8fabd87b071e26145c3d3aca4d38ef98

Contents?: true

Size: 1.7 KB

Versions: 40

Compression:

Stored size: 1.7 KB

Contents

require "pathname"

module VagrantPlugins
  module HostRedHat
    module Cap
      class NFS
        def self.nfs_check_command(env)
          if Vagrant::Util::Platform.systemd?
            "systemctl status --no-pager nfs-server.service"
          else
            "#{nfs_server_binary} status"
          end
        end

        def self.nfs_start_command(env)
          if Vagrant::Util::Platform.systemd?
            "systemctl start nfs-server.service"
          else
            "#{nfs_server_binary} start"
          end
        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

40 entries across 36 versions & 5 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/hosts/redhat/cap/nfs.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.3.3.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.3.2.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.19.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.18.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.16.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.14.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.10.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.9.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.8.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.7.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.6.2 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.6.1 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.6.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.5.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.4.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.3.0 plugins/hosts/redhat/cap/nfs.rb
vagrant-unbundled-2.2.2.0 plugins/hosts/redhat/cap/nfs.rb