Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#bindObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/facter/isp3node.rb', line 26

def bind()
  b = {
    :installed => package_installed?('bind9')
  }
  if(b[:installed])
    b[:version] = package_version('bind9'),
    b[:haveged] = package_version('haveged')
  end
  b
end

#dovecotObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/facter/isp3node.rb', line 37

def dovecot()
  d = {
    :installed => package_installed?('dovecot-core')
  }
  if(d[:installed])
    d[:version] = package_version('dovecot-core')
    d[:rspamd] = package_version('rspamd')
    Dir.chdir('/var/vmail') do
      d[:domains] = Dir.glob('*.*').select{|f| File.directory? f}
    end
  end
  d
end

#fail2banObject



51
52
53
54
55
56
57
58
59
# File 'lib/facter/isp3node.rb', line 51

def fail2ban()
  f2b = {
    :installed => package_installed?('fail2ban')
  }
  if(f2b[:installed])
    f2b[:version] = package_version('fail2ban')
  end
  f2b
end

#ispconfigObject



61
62
63
64
65
66
67
68
69
70
# File 'lib/facter/isp3node.rb', line 61

def ispconfig()
  isp = {
    :installed => File.exists?('/usr/local/ispconfig')
  }
  if(isp[:installed])
    isp[:version_interface] = Facter::Core::Execution.execute('grep "\'ISPC_APP_VERSION\'" /usr/local/ispconfig/interface/lib/config.inc.php | cut -d "\'" -f 4', {on_fail: false}),
    isp[:version_server] = Facter::Core::Execution.execute('grep "\'ISPC_APP_VERSION\'" /usr/local/ispconfig/server/lib/config.inc.php | cut -d "\'" -f 4', {on_fail: false})
  end
  isp
end

#jailkitObject



72
73
74
75
76
77
78
79
80
# File 'lib/facter/isp3node.rb', line 72

def jailkit()
  jk = {
    :installed => package_installed?('jailkit')
  }
  if(jk[:installed])
    jk[:version] = package_version('jailkit')
  end
  jk
end

#listen_portsObject



21
22
23
24
# File 'lib/facter/isp3node.rb', line 21

def listen_ports()
  portlist = Facter::Core::Execution.execute("netstat -tulpn | grep LISTEN | awk '{ print $4\"/\"$1 }' | rev | cut -d ':' -f 1 | rev", {on_fail: ''}).split("\n")
  portlist
end

#mailmanObject



82
83
84
85
86
87
88
89
90
# File 'lib/facter/isp3node.rb', line 82

def mailman()
  mm = {
    :installed => package_installed?('mailman')
  }
  if(mm[:installed])
    mm[:version] = package_installed?('mailman')
  end
  mm
end

#mysqlObject



92
93
94
95
96
97
98
99
100
# File 'lib/facter/isp3node.rb', line 92

def mysql()
  ms = {
    :installed => !!Facter.value('mysqld_version')
  }
  if(ms[:installed])
    ms[:version] = package_version('mariadb-server')
  end
  ms
end

#nginxObject



102
103
104
105
106
107
108
109
110
# File 'lib/facter/isp3node.rb', line 102

def nginx()
  nx = {
    :installed => !!Facter.value('nginx_version')
  }
  if(nx[:installed])
    nx[:version] = Facter.value('nginx_version')
  end
  nx
end

#package_installed?(package) ⇒ Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/facter/isp3node.rb', line 150

def package_installed?(package)
  Facter::Core::Execution.execute("dpkg -s #{package} > /dev/null && echo true", {:on_fail => 'false'}) == 'true'
end

#package_version(package) ⇒ Object



154
155
156
# File 'lib/facter/isp3node.rb', line 154

def package_version(package)
  Facter::Core::Execution.execute("dpkg -s #{package} | grep --line-buffered Version | awk '{print $2}'", {:on_fail => ''})
end

#postfixObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/facter/isp3node.rb', line 112

def postfix()
  pf = {
    :installed => package_installed?('postfix')
  }
  if(pf[:installed])
    pf[:version] = package_version('postfix')
    relay = Facter::Core::Execution.execute("postconf -h relayhost", :on_fail => '')
    if(relay == '')
      pf[:mode] = 'standalone'
    else
      pf[:mode] = 'satellite'
      pf[:relay] = relay
    end
    pf[:allowed_hosts] = Facter::Core::Execution.execute("postconf -h mynetworks", :on_fail => '').split(' ')
  end
  pf
end

#pureftpdObject



130
131
132
133
134
135
136
137
138
# File 'lib/facter/isp3node.rb', line 130

def pureftpd()
  pf = {
    :installed => package_installed?('pure-ftpd-common')
  }
  if(pf[:installed])
    pf[:version] = package_version('pure-ftpd-common')
  end
  pf
end

#roundcubeObject



140
141
142
143
144
145
146
147
148
# File 'lib/facter/isp3node.rb', line 140

def roundcube()
  rc = {
    :installed => package_installed?('roundcube')
  }
  if(rc[:installed])
    rc[:version] = package_version('roundcube')
  end
  rc
end