Sha256: 4a5e54185344e4ba8d0f07bd3488557231afee5c638a81cd25741dd92ad23cd6

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'fileutils'

module Getch
  module FileSystem
    module Lvm
      class Mount < Getch::FileSystem::Lvm::Device
        def initialize
          super
          @root_dir = MOUNTPOINT
          @boot_dir = "#{@root_dir}/boot"
          @boot_efi_dir = "#{@root_dir}/boot/efi"
          @home_dir = @user ? "#{@root_dir}/home/#{@user}" : nil
          @state = Getch::States.new()
        end

        def run
          return if STATES[:mount]
          mount_swap
          mount_root
          mount_boot
          mount_home
          mount_boot_efi
          @state.mount
        end

        private

        def mount_swap
          return if ! @lv_swap
          system("swapon #{@lv_swap}")
        end

        def mount_root
          return if ! @lv_root
          Dir.mkdir(@root_dir, 0700) if ! Dir.exist?(@root_dir)
          system("mount #{@lv_root} #{@root_dir}")
        end

        def mount_boot_efi
          return if ! @dev_boot_efi
          FileUtils.mkdir_p @boot_efi_dir, mode: 0700 if ! Dir.exist?(@boot_efi_dir)
          system("mount #{@dev_boot_efi} #{@boot_efi_dir}")
        end

        def mount_boot
          return if ! @dev_boot
          FileUtils.mkdir_p @boot_dir, mode: 0700 if ! Dir.exist?(@boot_dir)
          system("mount #{@dev_boot} #{@boot_dir}")
        end

        def mount_home
          return if ! @lv_home
          if @user != nil then
            FileUtils.mkdir_p @home_dir, mode: 0700 if ! Dir.exist?(@home_dir)
            system("mount #{@lv_home} #{@home_dir}")
          end
          @state.mount
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
getch-0.1.0 lib/getch/filesystem/lvm/mount.rb
getch-0.0.9 lib/getch/filesystem/lvm/mount.rb
getch-0.0.8 lib/getch/filesystem/lvm/mount.rb