Sha256: 5db825acaa880ff3f1f618bfcdb066879757ce76148e08b03fd18aec5a912312

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Getch
  module Config
    # Configure iwd if wifi is detected
    class Iwd
      include NiTo

      def initialize
        @options = "[General]\nUseDefaultInterface=true\n"
        x
      end

      protected

      def x
        runit
        systemd
        openrc
      end

      private

      # https://docs.voidlinux.org/config/network/iwd.html
      def runit
        Helpers.runit? || return

        iwd_conf
        service = '/etc/runit/runsvdir/default/'
        Chroot.new("ln -fs /etc/sv/dbus #{service}")
        Chroot.new("ln -fs /etc/sv/iwd #{service}")
      end

      def systemd
        Helpers.systemd? || return

        iwd_conf
        Chroot.new('systemctl enable iwd')
      end

      def openrc
        Helpers.openrc? || return

        iwd_conf
        Chroot.new('rc-update add iwd default')
      end

      # https://docs.voidlinux.org/config/network/iwd.html#troubleshooting
      def iwd_conf
        conf = "#{OPTIONS[:mountpoint]}/etc/iwd/main.conf"
        content = @options.dup
        content << "[Network]\n"
        content << if Helpers.systemd?
                     "NameResolvingService=systemd\n"
                   else
                     "NameResolvingService=resolvconf\n"
                   end
        mkdir "#{OPTIONS[:mountpoint]}/etc/iwd"
        echo conf, "#{content}\n"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
getch-0.11.0 lib/getch/config/iwd.rb
getch-0.7.3 lib/getch/config/iwd.rb
getch-0.7.0 lib/getch/config/iwd.rb
getch-0.5.0 lib/getch/config/iwd.rb