murakumo 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -16,8 +16,7 @@ https://bitbucket.org/winebarrel/murakumo
16
16
  == Install
17
17
 
18
18
  shell> gem install murakumo
19
- shell> cp /usr/local/lib/ruby/gems/1.8/gems/murakumo-*/etc/murakumo.server /etc/init.d/murakumo
20
- shell> chmod 755 /etc/init.d/murakumo
19
+ shell> murakumo-install-init-script
21
20
  shell> /etc/init.d/murakumo configure
22
21
  shell> /etc/init.d/murakumo start
23
22
  shell> dig @127.0.0.1 <any_hostname>
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ MRKM_DIR = 'murakumo-0.1.4'
3
+ INIT_D_DIR = '/etc/init.d'
4
+
5
+ begin
6
+ require 'rbconfig'
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ end
10
+
11
+ gem_dir = nil
12
+
13
+ if defined?(Gem)
14
+ gem_dir = "#{Gem.dir}/gems"
15
+ elsif defined?(RbConfig)
16
+ gem_dir = RbConfig::CONFIG["rubylibdir"].sub(/\d+\.\d+\Z/) {|m| "gems/#{m}/gems"}
17
+ else
18
+ $stderr.puts 'error: gem dir is not found.'
19
+ exit 1
20
+ end
21
+
22
+ `cp -i #{gem_dir}/#{MRKM_DIR}/etc/murakumo.server #{INIT_D_DIR}/murakumo`
23
+ `chmod 755 #{INIT_D_DIR}/murakumo`
@@ -0,0 +1,13 @@
1
+ --- /sbin/dhclient-script.orig 2011-04-13 07:30:32.000000000 +0900
2
+ +++ /sbin/dhclient-script 2011-11-20 00:18:31.000000000 +0900
3
+ @@ -65,6 +65,10 @@
4
+ if [ -n "$RES_OPTIONS" ]; then
5
+ echo options $RES_OPTIONS >> $rscf
6
+ fi
7
+ + CURRENT_RUN_LEVEL=(`/sbin/runlevel`)
8
+ + if [ -n "${CURRENT_RUN_LEVEL[1]}" -a ${CURRENT_RUN_LEVEL[1]} -ge 3 ]; then
9
+ + echo nameserver 127.0.0.1 >> $rscf
10
+ + fi
11
+ for nameserver in $new_domain_name_servers; do
12
+ echo nameserver $nameserver >> $rscf
13
+ done
@@ -0,0 +1,33 @@
1
+ #!/bin/sh
2
+ CURL='curl --retry 3 --retry-delay 0 --silent --fail'
3
+ IP_ADDR=`$CURL http://169.254.169.254/1.0/meta-data/local-ipv4`
4
+ CONF=/etc/murakumo.yml
5
+
6
+ if [ $? -ne 0 -o -z "$IP_ADDR" ]; then
7
+ exit 1
8
+ fi
9
+
10
+ if [ `grep ^host $CONF | egrep "host: $IP_ADDR\b" | wc -l` -eq 1 ]; then
11
+ exit
12
+ fi
13
+
14
+ ## gets a host name from user data.
15
+ #HOSTNAME=`$CURL http://169.254.169.254/1.0/user-data`
16
+
17
+ ## gets a host name from name tag.
18
+ #export JAVA_HOME=/usr/java/default
19
+ #export EC2_HOME=/opt/ec2-api-tools
20
+ #EC2_PRIVATE_KEY=
21
+ #EC2_CERT=
22
+ #REGION=ap-northeast-1
23
+ #EC2DIN=$EC2_HOME/bin/ec2-describe-instances
24
+ #HOSTNAME=`$EC2DIN -K $EC2_PRIVATE_KEY -C $EC2_CERT --region $REGION -F "private-ip-address=$IP_ADDR" | awk -F'\t' '$1 == "TAG" && $4 == "Name" {print $5}'`
25
+
26
+ ## gets a host name from meta data.
27
+ HOSTNAME=`$CURL http://169.254.169.254/1.0/meta-data/hostname`
28
+
29
+ if [ $? -ne 0 -o -z "$HOSTNAME" ]; then
30
+ exit 1
31
+ fi
32
+
33
+ sed -i.bak -r "s|^host:.*|host: $IP_ADDR, $HOSTNAME|" /etc/murakumo.yml
data/etc/murakumo.server CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
- # chkconfig: 345 64 36
2
+ # chkconfig: 345 11 89
3
3
  # description: The internal DNS server which manages name information using a gossip protocol.
4
4
  # processname: /usr/local/bin/murakumo
5
5
  # config: /etc/murakumo.yml
@@ -13,6 +13,8 @@ if [ "$1" != "configure" -a ! -e "$conf" ]; then
13
13
  exit 1
14
14
  fi
15
15
 
16
+ #/usr/local/sbin/murakumo-update-config-for-ec2
17
+
16
18
  case "$1" in
17
19
  start)
18
20
  $prog -c $conf -d start
@@ -64,6 +66,7 @@ resolver: $resolver
64
66
  max-ip-number: 8
65
67
 
66
68
  #initial-nodes: 10.11.12.14, 10.11.12.15
69
+ #domain: ap-northeast-1.compute.internal
67
70
 
68
71
  host: $ip_addr, $hostname, 60
69
72
 
@@ -9,6 +9,7 @@ resolver: 8.8.8.8
9
9
  max-ip-num: 8
10
10
 
11
11
  #initial-nodes: 10.11.12.14, 10.11.12.15
12
+ #domain: ap-northeast-1.compute.internal
12
13
 
13
14
  # Ip address, hostname, ttl
14
15
  host: 10.11.12.13, my-host, 60
@@ -81,6 +81,11 @@ def murakumo_parse_args
81
81
  invalid_argument if value < 1
82
82
  end
83
83
 
84
+ desc 'suffix of a host name'
85
+ option :domain, '-b', '--domain DOMAIN' do |value|
86
+ invalid_argument if (value || '').strip.empty?
87
+ end
88
+
84
89
  desc 'command of daemonize: {start|stop|restart|status}'
85
90
  option :daemon, '-d', '--daemon CMD', :type => [:start, :stop, :restart, :status]
86
91
 
@@ -1,5 +1,5 @@
1
1
  module Murakumo
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
 
4
4
  # Priority
5
5
  MASTER = 1
@@ -70,7 +70,7 @@ module Murakumo
70
70
 
71
71
  if health_check.kind_of?(Hash)
72
72
  health_check.each do |name, conf|
73
- checker = HealthChecker.new(name, self, options[:logger], conf)
73
+ checker = HealthChecker.new(name.downcase, self, options[:logger], conf)
74
74
  @health_checkers[name] = checker
75
75
  # ヘルスチェックはまだ起動しない
76
76
  end
@@ -105,6 +105,7 @@ module Murakumo
105
105
  ]},
106
106
  :socket => 'socket',
107
107
  :max_ip_num => 'max-ip-num',
108
+ :domain => 'domain',
108
109
  :log_path => 'log-path',
109
110
  :log_level => 'log-level',
110
111
  :gossip_port => 'gossip-port',
@@ -343,6 +344,9 @@ module Murakumo
343
344
  # 名前は小文字に変換
344
345
  name = name.downcase
345
346
 
347
+ # ドメインが指定されていたら削除
348
+ name.sub!(/\.#{Regexp.escape(@options[:domain])}\Z/i, '') if @options[:domain]
349
+
346
350
  # シングルスレッドェ…
347
351
  @address_records = @db.execute(<<-EOS, name, ACTIVE)
348
352
  SELECT ip_address, ttl, priority FROM records
@@ -9,8 +9,7 @@ module Murakumo
9
9
  class HealthChecker
10
10
 
11
11
  def initialize(name, cloud, logger, options)
12
- # 名前は小文字に変換
13
- @name = name.downcase
12
+ @name = name
14
13
  @cloud = cloud
15
14
  @logger = logger
16
15
 
@@ -34,6 +34,9 @@ module Murakumo
34
34
 
35
35
  on(:start) do
36
36
  if @@options[:socket]
37
+ # 既存のソケットファイルは削除
38
+ FileUtils.rm_f(@@options[:socket])
39
+
37
40
  # ServerクラスをDRuby化
38
41
  DRb.start_service("drbunix:#{@@options[:socket]}", @@cloud)
39
42
  at_exit { FileUtils.rm_f(@@options[:socket]) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: murakumo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - winebarrel
@@ -86,12 +86,14 @@ email: sgwr_dts@yahoo.co.jp
86
86
  executables:
87
87
  - murakumo
88
88
  - mrkmctl
89
+ - murakumo-install-init-script
89
90
  extensions: []
90
91
 
91
92
  extra_rdoc_files: []
92
93
 
93
94
  files:
94
95
  - README
96
+ - bin/murakumo-install-init-script
95
97
  - bin/mrkmctl
96
98
  - bin/murakumo
97
99
  - lib/cli/murakumo_options.rb
@@ -103,7 +105,9 @@ files:
103
105
  - lib/srv/murakumo_health_checker.rb
104
106
  - lib/srv/murakumo_cloud.rb
105
107
  - lib/misc/murakumo_const.rb
108
+ - etc/murakumo-update-config-for-ec2
106
109
  - etc/murakumo.yml.sample
110
+ - etc/dhclient-script.patch
107
111
  - etc/murakumo.server
108
112
  homepage: https://bitbucket.org/winebarrel/murakumo
109
113
  licenses: []