value-domain-ddns 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/value-domain-ddns +1 -30
- data/lib/value-domain-ddns.rb +2 -0
- data/lib/value-domain-ddns/cli.rb +29 -0
- data/lib/value-domain-ddns/logger.rb +8 -0
- data/lib/value-domain-ddns/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc88e0426489f0df3b22c1d169a3f4919c15c115
|
4
|
+
data.tar.gz: 6cc724f0354f7ec0cdaf8ed91228de0263e3c228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 233f1805b0f261ae45535136d851bfc1d8aec67df7c70e6dc6218d9939f9f520a46b8c615bb5f16857ab34d9d6888af50c32072627f9fd329dd0055087004e0c
|
7
|
+
data.tar.gz: 54d088030f66eaec346c9fd9b19e0501725d625fa2f8406d22a24862f6967859455ba62f99d37fb924ba6cc5f8007cb3500d8daf869e74506654bee6afc0954a
|
data/bin/value-domain-ddns
CHANGED
@@ -2,36 +2,7 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.expand_path("../../lib", __FILE__)
|
4
4
|
|
5
|
-
require "value-domain-ddns"
|
6
|
-
|
7
5
|
require 'rubygems'
|
8
|
-
require
|
9
|
-
|
10
|
-
class ValueDomainDdns::Cli < Thor
|
11
|
-
options :domain => :string, :password => :string,
|
12
|
-
:hostname => :string, :ip => :string
|
13
|
-
options :config => :string
|
14
|
-
desc "sync", "update and sync ddns record"
|
15
|
-
long_desc <<-EOD
|
16
|
-
Update and sync ddns record.
|
17
|
-
Default config file is `./config.json`.
|
18
|
-
If other fields are set, it overwrites config file's value.
|
19
|
-
EOD
|
20
|
-
def sync
|
21
|
-
config_file = options[:config] || "./config.json"
|
22
|
-
config = ValueDomainDdns::Config.load(config_file)
|
23
|
-
ddns = ValueDomainDdns::Core.new(config)
|
24
|
-
if !ddns.validate
|
25
|
-
STDERR.puts "domain, password, hostname are required."
|
26
|
-
exit
|
27
|
-
end
|
28
|
-
config[:ip] = ddns.get_ip if !config[:ip]
|
29
|
-
params = ddns.submit_params
|
30
|
-
params["p"] = '******'
|
31
|
-
puts "update to #{ValueDomainDdns::SUBMIT_BASE_URL} with params:"
|
32
|
-
p params
|
33
|
-
puts ddns.sync()
|
34
|
-
end
|
35
|
-
end
|
6
|
+
require "value-domain-ddns"
|
36
7
|
|
37
8
|
ValueDomainDdns::Cli.start(ARGV)
|
data/lib/value-domain-ddns.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
class ValueDomainDdns::Cli < Thor
|
4
|
+
options :domain => :string, :password => :string,
|
5
|
+
:hostname => :string, :ip => :string
|
6
|
+
options :config => :string
|
7
|
+
options :logfile => :string
|
8
|
+
desc "sync", "update and sync ddns record"
|
9
|
+
long_desc <<-EOD
|
10
|
+
Update and sync ddns record.
|
11
|
+
Default config file is `./config.json`.
|
12
|
+
If other fields are set, it overwrites config file's value.
|
13
|
+
EOD
|
14
|
+
def sync
|
15
|
+
config_file = options[:config] || "./config.json"
|
16
|
+
config = ValueDomainDdns::Config.load(config_file)
|
17
|
+
ddns = ValueDomainDdns::Core.new(config)
|
18
|
+
log = ValueDomainDdns::Logger.new(options[:logfile] || STDOUT, Logger::INFO)
|
19
|
+
if !ddns.validate
|
20
|
+
STDERR.puts "domain, password, hostname are required."
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
config[:ip] = ddns.get_ip if !config[:ip]
|
24
|
+
params = ddns.submit_params
|
25
|
+
params["p"] = '******'
|
26
|
+
log.info("update to #{ValueDomainDdns::SUBMIT_BASE_URL} with params:"+params.to_s)
|
27
|
+
log.info(ddns.sync())
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: value-domain-ddns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- daimatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -83,9 +83,11 @@ files:
|
|
83
83
|
- bin/value-domain-ddns
|
84
84
|
- config.json
|
85
85
|
- lib/value-domain-ddns.rb
|
86
|
+
- lib/value-domain-ddns/cli.rb
|
86
87
|
- lib/value-domain-ddns/config.rb
|
87
88
|
- lib/value-domain-ddns/constant.rb
|
88
89
|
- lib/value-domain-ddns/core.rb
|
90
|
+
- lib/value-domain-ddns/logger.rb
|
89
91
|
- lib/value-domain-ddns/version.rb
|
90
92
|
- spec/spec_helper.rb
|
91
93
|
- spec/value-domain-ddns/config_spec.rb
|