Class: Getch::Mount

Inherits:
Object
  • Object
show all
Defined in:
lib/getch/mount.rb

Instance Method Summary collapse

Constructor Details

#initialize(disk, user) ⇒ Mount

Returns a new instance of Mount.



5
6
7
8
9
10
11
12
# File 'lib/getch/mount.rb', line 5

def initialize(disk, user)
  @disk = disk
  @user = user
  @dest = MOUNTPOINT
  @boot_efi = MOUNTPOINT + '/boot/efi'
  @home = @user == nil ? MOUNTPOINT + '/home' : MOUNTPOINT + "/home/#{@user}"
  @state = Getch::States.new()
end

Instance Method Details

#bootObject



25
26
27
28
29
30
31
# File 'lib/getch/mount.rb', line 25

def boot
  return if STATES[:mount]
  if Helpers::efi? then
    FileUtils.mkdir_p @boot_efi, mode: 0700 if ! Dir.exist?(@boot_efi)
    system("mount /dev/#{@disk}1 #{@boot_efi}")
  end
end

#homeObject



33
34
35
36
37
38
39
40
41
# File 'lib/getch/mount.rb', line 33

def home
  return if STATES[:mount]
  if @user != nil then
    FileUtils.mkdir_p @home, mode: 0700 if ! Dir.exist?(@home)
    system("mount /dev/#{@disk}4 #{@home}")
    FileUtils.chown @user, @user, @home
  end
  @state.mount
end

#rootObject



19
20
21
22
23
# File 'lib/getch/mount.rb', line 19

def root
  return if STATES[:mount]
  Dir.mkdir(@dest, 0700) if ! Dir.exist?(@dest)
  system("mount /dev/#{@disk}3 #{@dest}") 
end

#swapObject



14
15
16
17
# File 'lib/getch/mount.rb', line 14

def swap
  return if STATES[:mount]
  system("swapon /dev/#{@disk}2")
end