~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to lib/puppet/provider/mount.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
module Puppet::Provider::Mount
9
9
    # This only works when the mount point is synced to the fstab.
10
10
    def mount
11
 
        mountcmd @model[:name]
 
11
        # Manually pass the mount options in, since some OSes *cough*OS X*cough* don't
 
12
        # read from /etc/fstab but still want to use this type.
 
13
        args = []
 
14
        if self.options and self.options != :absent
 
15
            args << "-o" << self.options
 
16
        end
 
17
        args << resource[:name]
 
18
 
 
19
        if respond_to?(:flush)
 
20
            flush
 
21
        end
 
22
        mountcmd(*args)
 
23
    end
 
24
 
 
25
    def remount
 
26
        info "Remounting"
 
27
        if resource[:remounts] == :true
 
28
            mountcmd "-o", "remount", resource[:name]
 
29
        else
 
30
            unmount()
 
31
            mount()
 
32
        end
12
33
    end
13
34
 
14
35
    # This only works when the mount point is synced to the fstab.
15
36
    def unmount
16
 
        umount @model[:name]
 
37
        umount resource[:name]
17
38
    end
18
39
 
19
40
    # Is the mount currently mounted?
20
41
    def mounted?
21
 
        platform = Facter["operatingsystem"].value
22
 
        df = command(:df)
23
 
        case Facter["operatingsystem"].value
24
 
        # Solaris's df prints in a very weird format
25
 
        when "Solaris": df = "#{command(:df)} -k"
26
 
        end
27
 
        %x{#{df}}.split("\n").find do |line|
28
 
            fs = line.split(/\s+/)[-1]
29
 
            if platform == "Darwin"
30
 
                fs == "/private/var/automount" + @model[:name] or
31
 
                    fs == @model[:name]
 
42
        platform = Facter.value("operatingsystem")
 
43
        name = resource[:name]
 
44
        mounts = mountcmd.split("\n").find do |line|
 
45
            case platform
 
46
            when "Darwin"
 
47
                line =~ / on #{name} / or line =~ %r{ on /private/var/automount#{name}}
 
48
            when "Solaris"
 
49
                line =~ /^#{name} on /
32
50
            else
33
 
                fs == @model[:name]
 
51
                line =~ / on #{name} /
34
52
            end
35
53
        end
36
54
    end
37
55
end
38
 
 
39
 
# $Id: mount.rb 1860 2006-11-12 21:25:13Z luke $
 
 
b'\\ No newline at end of file'