wakeup 1.1 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1bd6911ede8e4519200aa7065243ba41938ed80
4
- data.tar.gz: a36b49bbf914a10b7d64c608853e1331fc7bb1a2
3
+ metadata.gz: b266f3c714283d95d34e4a204242929a1a9d48c9
4
+ data.tar.gz: bafcd1069c1108d25d78704b3bdd860fbf367fbc
5
5
  SHA512:
6
- metadata.gz: 1227a4d659b80b398374c037e07ac1a9b259c0842537221cc2d63b454422fc97ea597fa16a30d73c15bf372b00488b16687e35c0d14a82aa8c5d3ef74cafc607
7
- data.tar.gz: 3ee225d8bf091d779fc344c741ff7b742366013bac9ab2ed9c8e9d538fbd0ffcc3ade947d12af3aadcf13343a93210259cfd82a82e20c76c495f49de8252aa04
6
+ metadata.gz: 7b2abcc3f28fecf0604dedf6e861451d2c1aeae099793fa6c44822087d0688334c559664bb26d1db92abc3689324b85e4fa6329de6d144cd3a9b0b86a394cf31
7
+ data.tar.gz: 3ab49be4958f6774640e93011265f42dc37788222bdafa43729aa73f6797f1618bb9debe8d85b13a53cc61b0210614602cdd5a254b53a780260e19e92e37a3e8
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wakeup.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ankur Patel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ wakeup
2
+ =====
3
+
4
+ Wake-on-LAN command line tool to wake up a server given a domain/ip-address and MAC address
5
+
6
+ ## Install
7
+
8
+ `gem install wakeup` and you will now have `wakeup` command in your terminal.
9
+
10
+ ## Usage
11
+
12
+ You can wakeup a host by passing the ip address/hostname and optionally MAC address
13
+
14
+ `wakeup 192.168.1.11`
15
+
16
+ OR
17
+
18
+ `wakeup hostname`
19
+
20
+ OR
21
+
22
+ `wakeup some.host.com 01:23:45:67:89:ab`
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wakeup"
5
+ require "irb"
6
+
7
+ IRB.start
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "wakeup"
4
+
5
+ hostname, mac = ARGV
6
+
7
+ if hostname.nil?
8
+ puts "Missing hostname\nUsage: wakeup hostname [MAC Address]"
9
+ exit 1
10
+ end
11
+
12
+ mac ||= Wakeup::lookup_mac(hostname)
13
+ if mac.nil? || mac == ""
14
+ puts ["Unable to resolve hostname '#{hostname}' or discover MAC address for hostname.",
15
+ 'If hostname is correct try wakeup command with hostname and MAC address as such:',
16
+ "wakeup #{hostname} 00:11:22:AA:BB:CC"].join("\n")
17
+ exit 1
18
+ end
19
+
20
+ unless Wakeup::mac_address_valid?(mac)
21
+ puts "Invalid MAC address\nUsage: wakeup hostname [MAC Address]"
22
+ exit 1
23
+ end
24
+
25
+ Wakeup::Waker.wake(hostname, mac)
@@ -0,0 +1,27 @@
1
+ require "wakeup/version"
2
+ require "socket"
3
+
4
+ module Wakeup
5
+ extend self
6
+
7
+ def mac_address_valid?(mac)
8
+ mac =~ /^([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}$/
9
+ end
10
+
11
+ def lookup_mac(hostname)
12
+ `arp #{hostname} | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
13
+ end
14
+
15
+ class Waker
16
+ def self.wake(hostname, mac_addr)
17
+ udp_sock = UDPSocket.new
18
+ udp_sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
19
+ address = mac_addr.split(":").map(&:hex).map(&:chr).inject(:+).force_encoding("UTF-8")
20
+ data = "\xFF\xFF\xFF\xFF\xFF\xFF" + (address * 16) # Purposefully using double quotes
21
+ udp_sock.send(data, 0, "<broadcast>", Wakeup::PORT) # Need to send this before in order for it to work
22
+ udp_sock.send(data, 0, hostname, Wakeup::PORT)
23
+ puts "Wakeup command sent to host #{hostname}"
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,4 @@
1
+ module Wakeup
2
+ VERSION = "2.1"
3
+ PORT = 9
4
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wakeup/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wakeup"
8
+ spec.version = Wakeup::VERSION
9
+ spec.authors = ["Ankur Patel"]
10
+ spec.email = ["ankur.patel@ymail.com"]
11
+
12
+ spec.summary = %q{Wake-on-LAN command line tool}
13
+ spec.description = %q{Wake-on-LAN command line tool to wake up a server given a domain/ip-address and MAC address.}
14
+ spec.homepage = "https://github.com/ankurp/wakeup"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ end
metadata CHANGED
@@ -1,24 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wakeup
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankur Patel
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
13
27
  description: Wake-on-LAN command line tool to wake up a server given a domain/ip-address
14
- and MAC address
15
- email: ankur.patel@ymail.com
28
+ and MAC address.
29
+ email:
30
+ - ankur.patel@ymail.com
16
31
  executables:
17
32
  - wakeup
18
33
  extensions: []
19
34
  extra_rdoc_files: []
20
35
  files:
21
- - bin/wakeup
36
+ - ".gitignore"
37
+ - ".travis.yml"
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - bin/console
43
+ - bin/setup
44
+ - exe/wakeup
45
+ - lib/wakeup.rb
46
+ - lib/wakeup/version.rb
47
+ - wakeup.gemspec
22
48
  homepage: https://github.com/ankurp/wakeup
23
49
  licenses:
24
50
  - MIT
@@ -39,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
65
  version: '0'
40
66
  requirements: []
41
67
  rubyforge_project:
42
- rubygems_version: 2.2.2
68
+ rubygems_version: 2.4.5.1
43
69
  signing_key:
44
70
  specification_version: 4
45
71
  summary: Wake-on-LAN command line tool
data/bin/wakeup DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'socket'
3
-
4
- if ARGV.length != 2
5
- puts 'usage - wakeup 192.168.1.11 01:23:45:67:89:ab'
6
- exit
7
- end
8
-
9
- PORT = 80
10
- host, mac = ARGV
11
- if (mac =~ /^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$/).nil?
12
- puts 'invalid mac address'
13
- exit
14
- end
15
-
16
- address = mac.split(':').map(&:hex).map(&:chr).inject(:+).force_encoding('UTF-8')
17
- data = "\xFF\xFF\xFF\xFF\xFF\xFF" + (address * 16) # Purposefully using double quotes
18
-
19
- UDPSock = UDPSocket.new
20
- UDPSock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
21
- UDPSock.send(data, 0, '<broadcast>', PORT) # Need to send this before in order for it to work
22
- UDPSock.send(data, 0, host, PORT)
23
- puts "Wakeup command sent to #{host}"