Class: VagrantPlugins::SyncedFolderNFSGuest::GuestRedHat::Cap::NFSServer

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb

Class Method Summary collapse

Class Method Details

.nfs_check_command(machine) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 52

def self.nfs_check_command(machine)
  if systemd?(machine)
    machine.communicate.test(
      "systemctl status rpcbind nfs-server"
    )
  else
    machine.communicate.test(
      "service nfs status"
    )
  end
end

.nfs_server_install(machine) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 11

def self.nfs_server_install(machine)
  machine.communicate.sudo("yum -y install nfs-utils nfs-utils-lib")

  if systemd?(machine)
    machine.communicate.sudo("systemctl enable rpcbind nfs-server")
  else
    machine.communicate.sudo("chkconfig nfs on")

  end
end

.nfs_server_installed(machine) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 44

def self.nfs_server_installed(machine)
  if systemd?(machine)
    machine.communicate.test("systemctl status nfs-server.service")
  else
    machine.communicate.test("service nfs status")
  end
end

.nfs_setup_firewall(machine, ip) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 22

def self.nfs_setup_firewall(machine, ip)
  if not systemd?(machine)
    # centos 6.5 has iptables on by default is would seem
    machine.communicate.sudo(
      "sed -i \"s/#LOCKD_/LOCKD_/\" /etc/sysconfig/nfs"
    )
    machine.communicate.sudo(
      "sed -i \"s/#MOUNTD_PORT/MOUNTD_PORT/\" /etc/sysconfig/nfs"
    )
    machine.communicate.sudo(
      "iptables -I INPUT -m state --state NEW -p udp -m multiport " +
      "--dport 111,892,2049,32803 -s #{ip}/32 -j ACCEPT"
    )
    machine.communicate.sudo(
      "iptables -I INPUT -m state --state NEW -p tcp -m multiport " +
      "--dport 111,892,2049,32803 -s #{ip}/32 -j ACCEPT"
    )

    nfs_start_command(machine)
  end
end

.nfs_start_command(machine) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 64

def self.nfs_start_command(machine)
  if systemd?(machine)
    machine.communicate.sudo(
      "systemctl start rpcbind nfs-server",
      error_class: Errors::GuestNFSError,
      error_key: :nfs_start_failed
    )
  else
    ['rpcbind', 'nfs'].each do |i|
      machine.communicate.sudo(
        "service #{i} restart",
        error_class: Errors::GuestNFSError,
        error_key: :nfs_start_failed
      )
    end
  end
end

.systemd?(machine) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/vagrant-nfs_guest_vbfix/guests/redhat/cap/nfs_server.rb', line 7

def self.systemd?(machine)
  machine.communicate.test("test $(ps -o comm= 1) == 'systemd'")
end