do-dyndns 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -6
- data/bin/{dyndns → do_dyndns} +4 -3
- data/lib/do_dyndns.rb +5 -0
- data/lib/{dyndns → do_dyndns}/updater.rb +3 -2
- data/lib/do_dyndns/version.rb +3 -0
- metadata +19 -19
- data/lib/dyndns.rb +0 -5
- data/lib/dyndns/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec2df7936a50a97b7b9d57b1f25e93c4ba2009bd33935ffa5b8d2cd64b180db
|
4
|
+
data.tar.gz: 4e1808967f7082420bc107301839e8d761568bdf8c79e8370c6f3725ff862e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f6e904affc8d598b9ab6f1c6bd310f08aa127c918b6ec77ddfb2f0cbe32bf537c44a6396c650652b48673ecda54a764f04918ce0bf9d9cf40c43626c8a71a8
|
7
|
+
data.tar.gz: 15c243d17f0afedb3a018c1ccf01663cba6c74685df55cdbdcfaf4a574a51c2f4d27a39bdaab4e5d6ff797c84e55a54da6eb400059b7345e0823fed21a12a873
|
data/README.md
CHANGED
@@ -1,16 +1,44 @@
|
|
1
1
|
# DO-Dyndns
|
2
2
|
|
3
|
-
Automatically update DNS records on DigitalOcean
|
3
|
+
Automatically update DNS records on DigitalOcean to the current IP of the machine running the script.
|
4
4
|
|
5
5
|
Finds the wan IPv4 address of the server it's running on and
|
6
6
|
updates the corresponding DNS records on digital ocean.
|
7
7
|
|
8
|
+
This is useful if you don't have a static ip from your ISP.
|
9
|
+
|
8
10
|
## Installation
|
9
11
|
`$ gem install do-dyndns`
|
10
12
|
|
11
|
-
##
|
13
|
+
## Gemfile
|
14
|
+
|
15
|
+
`gem 'do-dyndns', '~> 0.3.0'`
|
16
|
+
|
17
|
+
`require 'do_dydns'`
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'do_dyndns'
|
23
|
+
|
24
|
+
updater = DoDyndns::Updater.new(
|
25
|
+
token: '...',
|
26
|
+
domains: {
|
27
|
+
'example.com' => [
|
28
|
+
'subdomain'
|
29
|
+
]
|
30
|
+
},
|
31
|
+
logger: Logger.new($stdout)
|
32
|
+
)
|
33
|
+
|
34
|
+
updater.update_ips # Updates 'subdomain.example.com' to your current IPv4 address
|
35
|
+
```
|
36
|
+
|
37
|
+
## CLI Configuration
|
38
|
+
When runninng `do_dyndns`, the updater reads a configuration file:
|
39
|
+
|
12
40
|
Configuration is located at:
|
13
|
-
`~/.config/dyndns.yml`
|
41
|
+
`~/.config/do-dyndns.yml`
|
14
42
|
|
15
43
|
if no config file is found, do-dyndns will create one and open it with your `$EDITOR`
|
16
44
|
|
@@ -21,19 +49,50 @@ if no config file is found, do-dyndns will create one and open it with your `$ED
|
|
21
49
|
- example-subdomain1
|
22
50
|
```
|
23
51
|
|
24
|
-
## Usage
|
52
|
+
## CLI Usage
|
25
53
|
```
|
26
|
-
$ dyndns
|
54
|
+
$ do-dyndns
|
27
55
|
I, [2019-03-26T14:39:20.643564 #11387] INFO -- : Started IP check
|
28
56
|
I, [2019-03-26T14:39:20.720905 #11387] INFO -- : Current WAN IP: **.**.**.**
|
29
57
|
I, [2019-03-26T14:39:21.977426 #11387] INFO -- : IPs Match for ***.***.***
|
30
58
|
```
|
31
59
|
|
32
60
|
## Automation
|
61
|
+
Following are examples on how to run this script periodically to update your VPS with the machine's current IP
|
33
62
|
|
34
63
|
### Cron:
|
35
64
|
Check every 15 minutes:
|
36
65
|
|
37
66
|
```
|
38
|
-
*/15 * * * * dyndns
|
67
|
+
*/15 * * * * /path/to/do-dyndns
|
68
|
+
```
|
69
|
+
|
70
|
+
|
71
|
+
### Launchctl
|
72
|
+
Check every 15 minutes:
|
73
|
+
|
74
|
+
```xml
|
75
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
76
|
+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
77
|
+
<plist version="1.0">
|
78
|
+
<dict>
|
79
|
+
<key>Label</key>
|
80
|
+
<string>com.pixelfaucet.do-dyndns</string>
|
81
|
+
|
82
|
+
<key>WorkingDirectory</key>
|
83
|
+
<string>~/</string>
|
84
|
+
|
85
|
+
<key>UserName</key>
|
86
|
+
<string>nobody</string>
|
87
|
+
|
88
|
+
<key>ProgramArguments</key>
|
89
|
+
<array>
|
90
|
+
<string>~/.rvm/wrappers/ruby-2.6.5@do-dyndns</string>
|
91
|
+
<string>do-dyndns</string>
|
92
|
+
</array>
|
93
|
+
|
94
|
+
<key>StartInterval</key>
|
95
|
+
<integer>900</integer>
|
96
|
+
</dict>
|
97
|
+
</plist>
|
39
98
|
```
|
data/bin/{dyndns → do_dyndns}
RENAMED
@@ -6,22 +6,23 @@ require 'yaml'
|
|
6
6
|
require 'fileutils'
|
7
7
|
require 'logger'
|
8
8
|
require 'shellwords'
|
9
|
-
require '
|
9
|
+
require 'do_dyndns'
|
10
10
|
|
11
11
|
LOG = Logger.new($stdout)
|
12
12
|
|
13
13
|
rpath = File.expand_path(File.dirname(__FILE__))
|
14
14
|
Dir.chdir rpath
|
15
15
|
|
16
|
-
config_path = File.expand_path "~/.config/dyndns.yml"
|
16
|
+
config_path = File.expand_path "~/.config/do-dyndns.yml"
|
17
17
|
|
18
18
|
if File.exist? config_path
|
19
19
|
config = YAML.load_file config_path
|
20
|
-
|
20
|
+
DoDyndns::Updater.new(**config, logger: LOG).update_ips
|
21
21
|
else
|
22
22
|
LOG.warn "No configuration exists @ #{config_path}: Creating file."
|
23
23
|
FileUtils.mkdir_p File.dirname(config_path)
|
24
24
|
FileUtils.cp("../config.example.yml", config_path)
|
25
25
|
editor = ENV['EDITOR'] || 'nano'
|
26
26
|
system "#{editor} #{Shellwords.shellescape(config_path)}"
|
27
|
+
LOG.info "Config created."
|
27
28
|
end
|
data/lib/do_dyndns.rb
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module DoDyndns
|
2
2
|
class Updater
|
3
3
|
require 'droplet_kit'
|
4
4
|
|
@@ -8,7 +8,7 @@ module Dyndns
|
|
8
8
|
@api = DropletKit::Client.new(access_token: token)
|
9
9
|
end
|
10
10
|
|
11
|
-
# Get the domains from DO's API and
|
11
|
+
# Get the domains from DO's API and select only ones specified in the config
|
12
12
|
def domains
|
13
13
|
@api.domains
|
14
14
|
.all
|
@@ -73,6 +73,7 @@ module Dyndns
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
+
# Try all the commands until one of them works
|
76
77
|
def resolve(commands)
|
77
78
|
_ip = nil
|
78
79
|
commands.each do |service|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do-dyndns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Clink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,77 +16,77 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: droplet_kit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.7.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.7.0
|
69
69
|
description: |
|
70
70
|
Finds the wan IPv4 address of the server it's running on and
|
71
71
|
updates the corresponding DNS records on digital ocean.
|
72
72
|
email:
|
73
73
|
- alexclink@gmail.com
|
74
74
|
executables:
|
75
|
-
-
|
75
|
+
- do_dyndns
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- README.md
|
80
80
|
- bin/console
|
81
|
-
- bin/
|
81
|
+
- bin/do_dyndns
|
82
82
|
- bin/setup
|
83
83
|
- config.example.yml
|
84
|
-
- lib/
|
85
|
-
- lib/
|
86
|
-
- lib/
|
84
|
+
- lib/do_dyndns.rb
|
85
|
+
- lib/do_dyndns/updater.rb
|
86
|
+
- lib/do_dyndns/version.rb
|
87
87
|
homepage: http://alexclink.com/gems/dyndns
|
88
88
|
licenses:
|
89
|
-
-
|
89
|
+
- MIT
|
90
90
|
metadata: {}
|
91
91
|
post_install_message:
|
92
92
|
rdoc_options: []
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.0.
|
106
|
+
rubygems_version: 3.0.6
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Automatically update DNS records on DigitalOcean
|
data/lib/dyndns.rb
DELETED
data/lib/dyndns/version.rb
DELETED