#!/usr/bin/env ruby # encoding: utf-8 # # This file is part of the devdnsd gem. Copyright (C) 2013 and above Shogun . # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php. # require "rubygems" require "devdnsd" Bovem::Application.create do localizer = Lazier::Localizer.new(:devdnsd, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../locales/")).i18n name "DevDNSd" description localizer.application_description version DevDNSd::Version::STRING option :configuration, [], {type: String, help: localizer.application_help_configuration, default: "~/.devdnsd/default.conf", meta: localizer.application_meta_file} option :tld, [], {type: String, help: localizer.application_help_tld, default: "dev", meta: localizer.application_meta_domain} option :port, [], {type: Integer, help: localizer.application_help_port, default: 7771, meta: localizer.application_meta_port} option :pid_file, [:P, "pid-file"], {type: String, help: localizer.application_help_pid_file, default: "~/.devdnsd/daemon.pid", meta: localizer.application_meta_file} option :log_file, [:l, "log-file"], {type: String, help: localizer.application_help_log_file, default: "~/.devdnsd/daemon.log", meta: localizer.application_meta_file} option :log_level, [:L, "log-level"], {type: Integer, help: localizer.application_help_log_level, default: 1, meta: localizer.application_meta_level} command :start do description localizer.command_start option :foreground, [:n, "foreground"], {help: localizer.application_help_foreground} action { |command| DevDNSd::Application.instance(command).action_start } end command :status do description localizer.command_status action { |command| command.application.options[:log_file].set("STDOUT") DevDNSd::Application.instance(command).action_status } end command :stop do description localizer.command_stop action { |command| DevDNSd::Application.instance(command).action_stop } end command :restart do description localizer.command_restart action { |command| DevDNSd::Application.instance(command).action_restart } end command :install do description localizer.command_install action { |command| command.application.options[:log_file].set("STDOUT") DevDNSd::Application.instance(command).action_install } end command :uninstall do description localizer.command_uninstall action { |command| command.application.options[:log_file].set("STDOUT") DevDNSd::Application.instance(command).action_uninstall } end command :clean do description localizer.command_clean action { |command| command.application.options[:log_file].set("STDOUT") app = DevDNSd::Application.instance(command) app.logger.warn(app.i18n.admin_privileges_warning) app.dns_update } end command :aliases do description localizer.command_aliases option :interface, [], {type: String, help: localizer.application_help_interface, default: "lo0", meta: localizer.application_meta_interface} option :addresses, [], {type: Array, help: localizer.application_help_addresses, meta: localizer.application_meta_addresses} option :start_address, [:s, "start-address"], {type: String, help: localizer.application_help_start_address, default: "10.0.0.1", meta: localizer.application_meta_address} option :aliases, [:S], {type: Integer, help: localizer.application_help_aliases, default: 5, meta: localizer.application_meta_aliases} option :add_command, [:A, "add-command"], {type: String, help: localizer.application_help_add_command, default: "sudo ifconfig {{interface}} alias {{address}}", meta: localizer.application_meta_command} option :remove_command, [:R, "remove-command"], {type: String, help: localizer.application_help_remove_command, default: "sudo ifconfig {{interface}} -alias {{address}}", meta: localizer.application_meta_command} option :dry_run, [:n, "dry-run"], {help: localizer.application_help_dry_run} command :add do description localizer.command_add action { |command| DevDNSd::Application.instance(command).action_add(command.parent.get_options) } end command :remove do description localizer.command_remove action { |command| DevDNSd::Application.instance(command).action_remove(command.parent.get_options) } end action do |command| self.commands["add"].execute(command.options[:dry_run].value) end end action do |command| DevDNSd::Application.instance(command).action_add(command.get_options) end end