Sha256: 96cffb5f50360d59d6199708b3adadffde0cd3386848b761e0edaf755e0d2b8a

Contents?: true

Size: 583 Bytes

Versions: 9

Compression:

Stored size: 583 Bytes

Contents

require "micro/errors"

module JDCMicro::Switcher

  class Darwin < Base
    def adminrun(command)
      JDCMicro.run_command("osascript", "-e 'do shell script \"#{command}\" with administrator privileges'")
    end

    def set_nameserver(domain, ip)
      File.open("/tmp/#{domain}", 'w') { |file| file.write("nameserver #{ip}") }
      adminrun("mkdir -p /etc/resolver;mv /tmp/#{domain} /etc/resolver/")
    end

    def unset_nameserver(domain, ip)
      raise JDCMicro::MCFError, "domain missing" unless domain
      adminrun("rm -f /etc/resolver/#{domain}")
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jdc-0.2.7 lib/micro/switcher/darwin.rb
jdc-0.2.5 lib/micro/switcher/darwin.rb
jdc-0.2.4 lib/micro/switcher/darwin.rb
jdc-0.2.3 lib/micro/switcher/darwin.rb
jdc-0.2.2 lib/micro/switcher/darwin.rb
jdc-0.2.3.pre lib/micro/switcher/darwin.rb
jdc-0.2.2.pre lib/micro/switcher/darwin.rb
jdc-0.2.1.pre lib/micro/switcher/darwin.rb
jdc-0.2.0 lib/micro/switcher/darwin.rb