copy_my_conf 0.0.1 → 0.1.1
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/lib/copy_my_conf.rb +10 -67
- data/lib/copy_my_conf/config.rb +26 -0
- data/lib/copy_my_conf/git.rb +14 -0
- data/lib/copy_my_conf/provisioner.rb +35 -0
- data/lib/copy_my_conf/ssh.rb +16 -0
- data/lib/copy_my_conf/vim.rb +17 -0
- metadata +8 -3
data/lib/copy_my_conf.rb
CHANGED
@@ -1,73 +1,16 @@
|
|
1
|
-
|
1
|
+
module CopyMyConf
|
2
|
+
class Plugin < Vagrant.plugin("2")
|
3
|
+
name "copy_my_conf"
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
prepare_ssh if config.ssh
|
7
|
-
end
|
8
|
-
|
9
|
-
def provision!
|
10
|
-
channel = env[:vm].channel
|
11
|
-
provision_ssh(channel) if config.ssh
|
12
|
-
provision_vim(channel) if config.vim
|
13
|
-
provision_git(channel) if config.git
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.config_class
|
17
|
-
Config
|
18
|
-
end
|
19
|
-
|
20
|
-
class Config < Vagrant::Config::Base
|
21
|
-
attr_accessor :ssh
|
22
|
-
attr_accessor :vim
|
23
|
-
attr_accessor :git
|
24
|
-
attr_accessor :user_home
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def tmp_root
|
30
|
-
"/tmp/copy_my_conf"
|
31
|
-
end
|
32
|
-
|
33
|
-
def prepare_ssh
|
34
|
-
env[:vm].config.vm.share_folder("ssh", "#{tmp_root}/ssh", "~/.ssh")
|
35
|
-
end
|
36
|
-
|
37
|
-
def prepare_git
|
38
|
-
`mkdir -p #{tmp_root}/git`
|
39
|
-
`cp ~/.gitconfig #{tmp_root}/git/`
|
40
|
-
env[:vm].config.vm.share_folder("git", "#{tmp_root}/git/", "#{tmp_root}/git")
|
41
|
-
end
|
42
|
-
|
43
|
-
def prepare_vim
|
44
|
-
`mkdir -p #{tmp_root}/vim`
|
45
|
-
["~/.vimrc", "~/.vim"].each do |file|
|
46
|
-
`cp -r #{file} #{tmp_root}/vim`
|
5
|
+
config(:copy_my_conf, :provisioner) do
|
6
|
+
require File.expand_path('../copy_my_conf/config', __FILE__)
|
7
|
+
Config
|
47
8
|
end
|
48
|
-
env[:vm].config.vm.share_folder("vim", "#{tmp_root}/vim/", "#{tmp_root}/vim")
|
49
|
-
end
|
50
9
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def provision_vim(channel)
|
57
|
-
puts "Copying your vim configuratios"
|
58
|
-
channel.execute("rm -rf #{user_home}/.vim*")
|
59
|
-
channel.execute("cp -r #{tmp_root}/vim/.??* ~/")
|
60
|
-
end
|
61
|
-
|
62
|
-
def provision_ssh(channel)
|
63
|
-
puts "Copying your ssh keys and config"
|
64
|
-
channel.sudo("mkdir -p #{tmp_root}/cached && chown -R vagrant #{tmp_root}/cached")
|
65
|
-
channel.execute("[[ -f #{user_home}/.ssh/authorized_keys ]] && mv #{user_home}/.ssh/authorized_keys #{tmp_root}/cached")
|
66
|
-
channel.execute("cp #{tmp_root}/ssh/* #{user_home}/.ssh")
|
67
|
-
channel.execute("cat #{tmp_root}/cached/authorized_keys >> #{user_home}/.ssh/authorized_keys") # So that `vagrant ssh` doesn't ask for password
|
68
|
-
end
|
10
|
+
provisioner :copy_my_conf do
|
11
|
+
require File.expand_path('../copy_my_conf/provisioner', __FILE__)
|
12
|
+
Provisioner
|
13
|
+
end
|
69
14
|
|
70
|
-
def user_home
|
71
|
-
config.user_home || "/home/vagrant"
|
72
15
|
end
|
73
16
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "git"
|
2
|
+
require_relative "ssh"
|
3
|
+
require_relative "vim"
|
4
|
+
|
5
|
+
module CopyMyConf
|
6
|
+
class Config < Vagrant.plugin("2", :config)
|
7
|
+
attr_accessor :user_home
|
8
|
+
|
9
|
+
def git
|
10
|
+
@git ||= CopyMyConf::Git.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def vim
|
14
|
+
@vim ||= CopyMyConf::Vim.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def ssh
|
18
|
+
@ssh ||=CopyMyConf::Ssh.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_enabled_attributes
|
22
|
+
[@ssh, @vim, @git].compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CopyMyConf
|
2
|
+
class Git
|
3
|
+
def prepare vm, tmp_root
|
4
|
+
`mkdir -p #{tmp_root}/git`
|
5
|
+
`cp ~/.gitconfig #{tmp_root}/git/`
|
6
|
+
vm.synced_folder("#{tmp_root}/git/", "#{tmp_root}/git", :id => "git")
|
7
|
+
end
|
8
|
+
|
9
|
+
def provision channel, user_home, tmp_root
|
10
|
+
puts "Copying your gitconfig"
|
11
|
+
channel.execute("cp #{tmp_root}/git/.gitconfig #{user_home}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module CopyMyConf
|
2
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
3
|
+
|
4
|
+
def configure(root_config)
|
5
|
+
`rm -rf /tmp/copy_my_conf`
|
6
|
+
@to_be_copied = []
|
7
|
+
config.all_enabled_attributes.each do |conf|
|
8
|
+
@to_be_copied << conf
|
9
|
+
conf.prepare root_config.vm, tmp_root
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def provision
|
14
|
+
channel = @machine.communicate
|
15
|
+
@to_be_copied.each do |conf|
|
16
|
+
conf.provision channel, user_home, tmp_root
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.config_class
|
21
|
+
Config
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def tmp_root
|
27
|
+
"/tmp/copy_my_conf"
|
28
|
+
end
|
29
|
+
|
30
|
+
def user_home
|
31
|
+
config.user_home || "/home/vagrant"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CopyMyConf
|
2
|
+
class Ssh
|
3
|
+
def prepare vm, tmp_root
|
4
|
+
vm.synced_folder("#{ENV['HOME']}/.ssh", "#{tmp_root}/ssh",:id => "ssh")
|
5
|
+
end
|
6
|
+
|
7
|
+
def provision channel, user_home, tmp_root
|
8
|
+
puts "Copying your ssh keys and config"
|
9
|
+
channel.sudo("mkdir -p #{tmp_root}/cached && chown -R vagrant #{tmp_root}/cached")
|
10
|
+
channel.execute("[[ -f #{user_home}/.ssh/authorized_keys ]] && mv #{user_home}/.ssh/authorized_keys #{tmp_root}/cached")
|
11
|
+
channel.execute("cp #{tmp_root}/ssh/* #{user_home}/.ssh")
|
12
|
+
channel.execute("cat #{tmp_root}/cached/authorized_keys >> #{user_home}/.ssh/authorized_keys") # So that `vagrant ssh` doesn't ask for password
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CopyMyConf
|
2
|
+
class Vim
|
3
|
+
def prepare vm, tmp_root
|
4
|
+
`mkdir -p #{tmp_root}/vim`
|
5
|
+
["~/.vimrc", "~/.vim"].each do |file|
|
6
|
+
`cp -r #{file} #{tmp_root}/vim`
|
7
|
+
end
|
8
|
+
vm.synced_folder("#{tmp_root}/vim", "#{tmp_root}/vim", :id => "vim")
|
9
|
+
end
|
10
|
+
|
11
|
+
def provision channel, user_home, tmp_root
|
12
|
+
puts "Copying your vim configuratios"
|
13
|
+
channel.execute("rm -rf #{user_home}/.vim*")
|
14
|
+
channel.execute("cp -r #{tmp_root}/vim/.??* ~/")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copy_my_conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
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-
|
12
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Copy your configurations easily into vagrant box
|
15
15
|
email: itsakshaymankar@gmail.com
|
@@ -17,6 +17,11 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- lib/copy_my_conf/config.rb
|
21
|
+
- lib/copy_my_conf/git.rb
|
22
|
+
- lib/copy_my_conf/provisioner.rb
|
23
|
+
- lib/copy_my_conf/ssh.rb
|
24
|
+
- lib/copy_my_conf/vim.rb
|
20
25
|
- lib/copy_my_conf.rb
|
21
26
|
homepage: http://github.com/akshaymankar/copy_my_conf
|
22
27
|
licenses: []
|
@@ -38,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
43
|
version: '0'
|
39
44
|
requirements: []
|
40
45
|
rubyforge_project:
|
41
|
-
rubygems_version: 1.8.
|
46
|
+
rubygems_version: 1.8.25
|
42
47
|
signing_key:
|
43
48
|
specification_version: 3
|
44
49
|
summary: Vagrant Provisioner to copy your configuration files into vagrant box
|