Sha256: eaeb6c8b7d26675f3a2a32592d11cbe5f94b74eb158111a4758257e26cf0c20f

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require 'fileutils'

module Getch
  module FileSystem
    module Zfs
      class Mount < Getch::FileSystem::Zfs::Device
        def initialize
          super
          @root_dir = MOUNTPOINT
          @mount = Getch::FileSystem::Mount.new
          @state = Getch::States.new
          @log = Getch::Log.new
        end

        def run
          return if STATES[:mount]
          exec("zpool export -a")
          exec("rm -rf #{MOUNTPOINT}/*")
          exec("zpool import -N -R #{MOUNTPOINT} #{@pool_name}")
          exec("zpool import -N -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
          @mount.swap(@dev_swap)
          mount_root
          mount_boot
          @mount.esp(@dev_esp)
          exec("zfs mount -a")
          @state.mount
        end

        private

        def mount_root
          Helpers::mkdir(@root_dir)
          exec("zfs mount #{@pool_name}/ROOT/gentoo")
        end

        def mount_boot
          return if ! @dev_boot
          exec("zfs mount #{@boot_pool_name}/BOOT/gentoo")
        end

        def exec(cmd)
          @log.info("==> #{cmd}")
          Helpers::sys(cmd)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
getch-0.1.5 lib/getch/filesystem/zfs/mount.rb
getch-0.1.3 lib/getch/filesystem/zfs/mount.rb
getch-0.1.2 lib/getch/filesystem/zfs/mount.rb
getch-0.1.1 lib/getch/filesystem/zfs/mount.rb