1 class CopyMyConf
< Vagrant
::Provisioners::Base
4 prepare_vim
if config
.vim
5 prepare_git
if config
.git
6 prepare_ssh
if config
.ssh
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
20 class Config
< Vagrant
::Config::Base
24 attr_accessor
:user_home
34 env[:vm].config
.vm
.share_folder("ssh", "#{tmp_root}/ssh", "~/.ssh")
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")
44 `mkdir -p #{tmp_root}/vim`
45 ["~/.vimrc", "~/.vim"].each
do |file
|
46 `cp -r #{file} #{tmp_root}/vim`
48 env[:vm].config
.vm
.share_folder("vim", "#{tmp_root}/vim/", "#{tmp_root}/vim")
51 def provision_git(channel
)
52 puts
"Copying your gitconfig"
53 channel
.execute("cp #{tmp_root}/git/.gitconfig ~/")
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/.??* ~/")
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
71 config
.user_home
|| "/home/vagrant"