Sha256: 6e6d5a9b4caac0f588c73e4f664b40a9133f5c5d957e0be8d9c3fafcff193dcf

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

#  Created by Luke Kanies on 2006-11-12.
#  Copyright (c) 2006. All rights reserved.

require 'puppet'

# A module just to store the mount/unmount methods.  Individual providers
# still need to add the mount commands manually.
module Puppet::Provider::Mount
    # This only works when the mount point is synced to the fstab.
    def mount
        # Manually pass the mount options in, since some OSes *cough*OS X*cough* don't
        # read from /etc/fstab but still want to use this type.
        args = []
        if self.options and self.options != :absent
            args << "-o" << self.options
        end
        args << resource[:name]

        if respond_to?(:flush)
            flush
        end
        mountcmd(*args)
    end

    def remount
        info "Remounting"
        if resource[:remounts] == :true
            mountcmd "-o", "remount", resource[:name]
        else
            unmount()
            mount()
        end
    end

    # This only works when the mount point is synced to the fstab.
    def unmount
        umount resource[:name]
    end

    # Is the mount currently mounted?
    def mounted?
        platform = Facter.value("operatingsystem")
        name = resource[:name]
        mounts = mountcmd.split("\n").find do |line|
            case platform
            when "Darwin"
                line =~ / on #{name} / or line =~ %r{ on /private/var/automount#{name}}
            when "Solaris"
                line =~ /^#{name} on /
            else
                line =~ / on #{name} /
            end
        end
    end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
puppet-0.25.5 lib/puppet/provider/mount.rb
puppet-0.25.4 lib/puppet/provider/mount.rb
puppet-0.25.3 lib/puppet/provider/mount.rb
puppet-0.24.9 lib/puppet/provider/mount.rb
puppet-0.25.2 lib/puppet/provider/mount.rb
puppet-0.25.1 lib/puppet/provider/mount.rb
puppet-0.25.0 lib/puppet/provider/mount.rb
puppet-0.24.0 lib/puppet/provider/mount.rb
puppet-0.24.2 lib/puppet/provider/mount.rb
puppet-0.24.3 lib/puppet/provider/mount.rb
puppet-0.24.4 lib/puppet/provider/mount.rb
puppet-0.24.1 lib/puppet/provider/mount.rb
puppet-0.24.5 lib/puppet/provider/mount.rb
puppet-0.24.6 lib/puppet/provider/mount.rb
puppet-0.24.7 lib/puppet/provider/mount.rb
puppet-0.24.8 lib/puppet/provider/mount.rb