onddo/proftpd-cookbook

View on GitHub
templates/default/plugins/proftpd.rb.erb

Summary

Maintainability
Test Coverage
#
# Author:: Xabier de Zuazo (<xabier@zuazo.org>)
#
# Copyright 2014, Onddo Labs, Sl.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

provides 'proftpd'
provides 'proftpd/version'
provides 'proftpd/compiled_in_modules'

proftpd Mash.new unless proftpd
proftpd[:version] = nil unless proftpd[:version]
proftpd[:compiled_in_modules] = Array.new unless proftpd[:compiled_in_modules]

status, stdout, stderr = run_command(:no_status_check => true, :command => 'proftpd -v')
if status == 0
  stdout.split("\n").each do |line|
    case line
    when /^ProFTPD Version (\d+\.\d+\.\d+[a-zA-Z]*)/
      proftpd[:version] = $1
    end
  end
end

status, stdout, stderr = run_command(:no_status_check => true, :command => 'proftpd -l')
if status == 0
  stdout.split("\n").each do |line|
    case line
    when /^ +mod_(.*)\.c$/
      proftpd[:compiled_in_modules].push($1)
    end
  end
end