Sha256: 94b4d3c4283f6ff913c2e6da598b8d56e98120be4ffeb3454a4244bd0df28381

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'fileutils'

module Getch
  module FileSystem
    module Zfs
      module Encrypt
        class Mount < Getch::FileSystem::Zfs::Encrypt::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
            exec("zfs load-key -a")
            @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
end

Version data entries

4 entries across 4 versions & 1 rubygems

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