Sha256: 51f19fbb2e0a4d40cc4e62ecae567c019d19fd499d6bc0769ab801a8bc4a9114

Contents?: true

Size: 714 Bytes

Versions: 12

Compression:

Stored size: 714 Bytes

Contents

module Hookit
  module Resource
    class Logrotate < Base

      field :path
      field :filesize
      field :max_size
      field :count

      actions :create
      default_action :create

      def initialize(name)
        path name unless path
        super
      end

      def run(action)
        case action
        when :create
          create!
        end
      end

      protected

      def create!
        case platform.os
        when 'sun'
          `logadm -c -w #{path} -s #{filesize ||= '10m'} -S #{max_size ||= '500m'} -C #{count ||= '10'} -N`
        else
          raise Hookit::Error::UnsupportedPlatform, "unsupported platform '#{platform.name}'"
        end
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hookit-0.12.3 lib/hookit/resource/logrotate.rb
hookit-0.12.2 lib/hookit/resource/logrotate.rb
hookit-0.12.1 lib/hookit/resource/logrotate.rb
hookit-0.12.0 lib/hookit/resource/logrotate.rb
hookit-0.11.2 lib/hookit/resource/logrotate.rb
hookit-0.11.1 lib/hookit/resource/logrotate.rb
hookit-0.11.0 lib/hookit/resource/logrotate.rb
hookit-0.10.0 lib/hookit/resource/logrotate.rb
hookit-0.9.2 lib/hookit/resource/logrotate.rb
hookit-0.9.0 lib/hookit/resource/logrotate.rb
hookit-0.8.0 lib/hookit/resource/logrotate.rb
hookit-0.7.11 lib/hookit/resource/logrotate.rb