lockpick 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,24 +1,44 @@
1
1
  # Lockpick
2
2
 
3
- TODO: Write a gem description
3
+ Allowing SSH access to the members of a GitHub team.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ ```lockpick``` is meant to be run as a script. You can either install it via Rubygems:
8
8
 
9
- gem 'lockpick'
10
-
11
- And then execute:
9
+ $ gem install lockpick
12
10
 
13
- $ bundle
11
+ You may need to use ```sudo``` if you are installing against the system Ruby...
12
+
13
+ Or clone this repo:
14
14
 
15
- Or install it yourself as:
15
+ $ git clone https://github.com/fredjean/lockpick.git
16
16
 
17
- $ gem install lockpick
17
+ You will probably need to run ```bundle install``` if you choose that path...
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```lockpick``` is a simple script that uses the GitHub APIs to retrieve the list of verified, public ssh keys for the
22
+ members of one or more teams.
23
+
24
+ All you need to do to run the lockpick script:
25
+
26
+ $ lockpick
27
+
28
+ You can also use cron to run it periodically. Adding the following line to your crontab:
29
+
30
+ 5 * * * *
31
+
32
+ ## First Run
33
+
34
+ The script uses [Ara's Main](https://github.com/ahoward/main) gem to run. It will open up an editor with a template
35
+ configuration:
36
+
37
+ ```ruby
38
+ ```
39
+
40
+ It will then proceed to pull the keys from GitHub. The configuration is stored under ```~/.lockpick/config.yml```
41
+
22
42
 
23
43
  ## Contributing
24
44
 
data/bin/lockpick CHANGED
@@ -26,6 +26,9 @@ Main {
26
26
  })
27
27
 
28
28
  def run
29
+ status = lock_file.flock(File::LOCK_EX|File::LOCK_NB)
30
+ exit(42) unless status == 0
31
+
29
32
  pull_ssh_keys!
30
33
  end
31
34
 
@@ -65,6 +68,10 @@ Main {
65
68
  github.users.keys.list(user: login).response.body
66
69
  end
67
70
 
71
+ def lock_file
72
+ @lock_file ||= File.open(File.join(state_path, ".lock"), 'w')
73
+ end
74
+
68
75
  mode(:shell) {
69
76
  def run
70
77
  require 'pry'
@@ -78,9 +85,6 @@ Main {
78
85
 
79
86
 
80
87
  BEGIN {
81
- status = DATA.flock(File::LOCK_EX|File::LOCK_NB)
82
- exit(42) unless status == 0
83
-
84
88
  require 'rubygems'
85
89
  require 'github_api'
86
90
  require 'map'
@@ -153,5 +157,9 @@ BEGIN {
153
157
  end
154
158
  }
155
159
 
160
+ END {
161
+ lock_file.close
162
+ }
163
+
156
164
  __END__
157
165
  ### We need something to lock on...
@@ -1,3 +1,3 @@
1
1
  module Lockpick
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lockpick.gemspec CHANGED
@@ -13,7 +13,9 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/fredjean/lockpick"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($/).reject do |f|
17
+ %w(Cheffile Cheffile.lock Vagrantfile upgrade-chef.sh).include?(f)
18
+ end
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
21
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockpick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: main
@@ -148,18 +148,14 @@ extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
150
  - .gitignore
151
- - Cheffile
152
- - Cheffile.lock
153
151
  - Gemfile
154
152
  - LICENSE.txt
155
153
  - README.md
156
154
  - Rakefile
157
- - Vagrantfile
158
155
  - bin/lockpick
159
156
  - lib/lockpick.rb
160
157
  - lib/lockpick/version.rb
161
158
  - lockpick.gemspec
162
- - upgrade-chef.sh
163
159
  homepage: https://github.com/fredjean/lockpick
164
160
  licenses:
165
161
  - MIT
@@ -175,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
171
  version: '0'
176
172
  segments:
177
173
  - 0
178
- hash: 4571190319562877000
174
+ hash: -1573546165165272002
179
175
  required_rubygems_version: !ruby/object:Gem::Requirement
180
176
  none: false
181
177
  requirements:
@@ -184,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
180
  version: '0'
185
181
  segments:
186
182
  - 0
187
- hash: 4571190319562877000
183
+ hash: -1573546165165272002
188
184
  requirements: []
189
185
  rubyforge_project:
190
186
  rubygems_version: 1.8.23
data/Cheffile DELETED
@@ -1,7 +0,0 @@
1
- site 'http://community.opscode.com/api/v1'
2
-
3
- cookbook 'apt'
4
- cookbook 'rbenv', :git => 'git://github.com/fnichol/chef-rbenv.git'
5
- cookbook 'ruby_build'
6
- cookbook 'vim'
7
- cookbook 'build-essential'
data/Cheffile.lock DELETED
@@ -1,20 +0,0 @@
1
- SITE
2
- remote: http://community.opscode.com/api/v1
3
- specs:
4
- apt (2.0.0)
5
- build-essential (1.4.0)
6
- ruby_build (0.8.0)
7
-
8
- GIT
9
- remote: git://github.com/fnichol/chef-rbenv.git
10
- ref: master
11
- sha: 9afb4e5da2e6212504a12de3bbbd410cd96100f6
12
- specs:
13
- rbenv (0.7.3)
14
-
15
- DEPENDENCIES
16
- apt (>= 0)
17
- build-essential (>= 0)
18
- rbenv (>= 0)
19
- ruby_build (>= 0)
20
-
data/Vagrantfile DELETED
@@ -1,126 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure("2") do |config|
5
- # All Vagrant configuration is done here. The most common configuration
6
- # options are documented and commented below. For a complete reference,
7
- # please see the online documentation at vagrantup.com.
8
-
9
- # Every Vagrant virtual environment requires a box to build off of.
10
- config.vm.box = "ubuntu-precise-64"
11
-
12
- # The url from where the 'config.vm.box' box will be fetched if it
13
- # doesn't already exist on the user's system.
14
- config.vm.box_url = "http://files.vagrantup.com/precise64.box"
15
-
16
- # Create a forwarded port mapping which allows access to a specific port
17
- # within the machine from a port on the host machine. In the example below,
18
- # accessing "localhost:8080" will access port 80 on the guest machine.
19
- # config.vm.network :forwarded_port, guest: 80, host: 8080
20
-
21
- # Create a private network, which allows host-only access to the machine
22
- # using a specific IP.
23
- # config.vm.network :private_network, ip: "192.168.33.10"
24
-
25
- # Create a public network, which generally matched to bridged network.
26
- # Bridged networks make the machine appear as another physical device on
27
- # your network.
28
- # config.vm.network :public_network
29
-
30
- # Share an additional folder to the guest VM. The first argument is
31
- # the path on the host to the actual folder. The second argument is
32
- # the path on the guest to mount the folder. And the optional third
33
- # argument is a set of non-required options.
34
- # config.vm.synced_folder "../data", "/vagrant_data"
35
-
36
- # Provider-specific configuration so you can fine-tune various
37
- # backing providers for Vagrant. These expose provider-specific options.
38
- # Example for VirtualBox:
39
- #
40
- # config.vm.provider :virtualbox do |vb|
41
- # # Don't boot with headless mode
42
- # vb.gui = true
43
- #
44
- # # Use VBoxManage to customize the VM. For example to change memory:
45
- # vb.customize ["modifyvm", :id, "--memory", "1024"]
46
- # end
47
- #
48
- # View the documentation for the provider you're using for more
49
- # information on available options.
50
-
51
- # Enable provisioning with Puppet stand alone. Puppet manifests
52
- # are contained in a directory path relative to this Vagrantfile.
53
- # You will need to create the manifests directory and a manifest in
54
- # the file base.pp in the manifests_path directory.
55
- #
56
- # An example Puppet manifest to provision the message of the day:
57
- #
58
- # # group { "puppet":
59
- # # ensure => "present",
60
- # # }
61
- # #
62
- # # File { owner => 0, group => 0, mode => 0644 }
63
- # #
64
- # # file { '/etc/motd':
65
- # # content => "Welcome to your Vagrant-built virtual machine!
66
- # # Managed by Puppet.\n"
67
- # # }
68
- #
69
- # config.vm.provision :puppet do |puppet|
70
- # puppet.manifests_path = "manifests"
71
- # puppet.manifest_file = "init.pp"
72
- # end
73
-
74
- # Enable provisioning with chef solo, specifying a cookbooks path, roles
75
- # path, and data_bags path (all relative to this Vagrantfile), and adding
76
- # some recipes and/or roles.
77
- #
78
-
79
- config.vm.provision :shell, path: 'upgrade-chef.sh'
80
- config.vm.provision :chef_solo do |chef|
81
- chef.cookbooks_path = "cookbooks"
82
- chef.add_recipe('apt')
83
- chef.add_recipe('build-essential')
84
- chef.add_recipe('ruby_build')
85
- chef.add_recipe('rbenv::system')
86
- chef.add_recipe('vim')
87
- chef.add_recipe('rbenv::vagrant')
88
-
89
- # You may also specify custom JSON attributes:
90
- chef.json = {
91
- rbenv: {
92
- rubies: [ "1.9.3-p385" ],
93
- upgrade: 'sync',
94
- global: '1.9.3-p385',
95
- gems: {
96
- '1.9.3-p385' => [
97
- { name: 'bundler' }
98
- ]
99
- }
100
- }
101
- }
102
- end
103
-
104
- # Enable provisioning with chef server, specifying the chef server URL,
105
- # and the path to the validation key (relative to this Vagrantfile).
106
- #
107
- # The Opscode Platform uses HTTPS. Substitute your organization for
108
- # ORGNAME in the URL and validation key.
109
- #
110
- # If you have your own Chef Server, use the appropriate URL, which may be
111
- # HTTP instead of HTTPS depending on your configuration. Also change the
112
- # validation key to validation.pem.
113
- #
114
- # config.vm.provision :chef_client do |chef|
115
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
116
- # chef.validation_key_path = "ORGNAME-validator.pem"
117
- # end
118
- #
119
- # If you're using the Opscode platform, your validator client is
120
- # ORGNAME-validator, replacing ORGNAME with your organization name.
121
- #
122
- # If you have your own Chef Server, the default validation client name is
123
- # chef-validator, unless you changed the configuration.
124
- #
125
- # chef.validation_client_name = "ORGNAME-validator"
126
- end
data/upgrade-chef.sh DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- sudo apt-get update
4
- sudo apt-get -y install curl
5
-
6
- sudo true && curl -L https://www.opscode.com/chef/install.sh | sudo bash