Sha256: ec45401491cbe3193dc92aea619f7b573edf87eca80ee99503f20fa23e1253a5

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'nito'

module Getch
  module Config
    class TimeZone
      include NiTo

      def initialize
        @log = Log.new
        @etc_timezone = "#{OPTIONS[:mountpoint]}/etc/timezone"
        @rc_conf = "#{OPTIONS[:mountpoint]}/etc/rc.conf"
        @openrc = "#{OPTIONS[:mountpoint]}/etc/conf.d/keymaps"
        @timezone = OPTIONS[:timezone]
        x
      end

      protected

      def x
        @log.info "Configuring timezone to #{@timezone}...\n"
        for_runit
        for_openrc
        for_systemd
      end

      private

      def for_runit
        return unless Helpers.runit?

        echo_a @rc_conf, "TIMEZONE=\"#{@timezone}\""
      end

      def for_openrc
        return unless Helpers.openrc?

        echo_a @etc_timezone, OPTIONS[:timezone]
        Getch::Chroot.new('emerge --config sys-libs/timezone-data')
      end

      def for_systemd
        return unless Helpers.systemd?

        src = "/usr/share/zoneinfo/#{OPTIONS[:timezone]}"
        dest = "/etc/localtime"
        Getch::Chroot.new('ln', '-sf', src, dest)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
getch-0.7.3 lib/getch/config/timezone.rb
getch-0.7.0 lib/getch/config/timezone.rb
getch-0.5.0 lib/getch/config/timezone.rb
getch-0.3.6 lib/getch/config/timezone.rb
getch-0.3.5 lib/getch/config/timezone.rb
getch-0.3.4 lib/getch/config/timezone.rb
getch-0.3.3 lib/getch/config/timezone.rb
getch-0.3.0 lib/getch/config/timezone.rb