Class: Snapback::Filesystem

Inherits:
Object
  • Object
show all
Defined in:
lib/snapback/filesystem.rb

Constant Summary collapse

LOCKED_FILES =
['.', '..', 'lost+found']

Class Method Summary collapse

Class Method Details

.mount(device, directory) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/snapback/filesystem.rb', line 6

def self.mount(device, directory)
  # If it's already mounted, don't worry
  mount_status = Open4::popen4("mountpoint -q #{directory}") do |pid, stdin, stdout, stderr|
  end

  if mount_status == 0 then
    return true
  end

  `mount #{device} #{directory}`
end

.move_mysql_files(from_directory, to_directory) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/snapback/filesystem.rb', line 30

def self.move_mysql_files(from_directory, to_directory)
  Dir.foreach(from_directory) do |filename|
    if !LOCKED_FILES.include?(filename) then
      run_command "Moving #{from_directory}/#{filename} to #{to_directory}",
        "mv #{from_directory}/#{filename} #{to_directory}"
    end
  end
end

.unmount(directory) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/snapback/filesystem.rb', line 18

def self.unmount(directory)
  # If it's already unmounted, don't worry
  mount_status = Open4::popen4("mountpoint -q #{directory}") do |pid, stdin, stdout, stderr|
  end

  if mount_status != 0 then
    return true
  end

  `umount #{directory}`
end