`create_unison` method implemented on the system
This commit is contained in:
parent
67ab68df89
commit
c7bbfcc5a1
|
@ -49,19 +49,9 @@ module Vagrant
|
|||
def mount_shared_folder(ssh, name, guestpath)
|
||||
ssh.exec!("sudo mkdir -p #{guestpath}")
|
||||
mount_folder(ssh, name, guestpath)
|
||||
chown(ssh, guestpath)
|
||||
ssh.exec!("sudo chown #{config.ssh.username} #{guestpath}")
|
||||
end
|
||||
|
||||
# def create_sync(ssh, opts)
|
||||
# crontab_entry = render_crontab_entry(opts.merge(:syncopts => config.vm.sync_opts,
|
||||
# :scriptname => config.vm.sync_script))
|
||||
|
||||
# ssh.exec!("sudo mkdir -p #{opts[:syncpath]}")
|
||||
# chown(ssh, opts[:syncpath])
|
||||
# ssh.exec!("sudo echo \"#{crontab_entry}\" >> #{config.vm.sync_crontab_entry_file}")
|
||||
# ssh.exec!("crontab #{config.vm.sync_crontab_entry_file}")
|
||||
# end
|
||||
|
||||
def prepare_unison(ssh)
|
||||
logger.info "Preparing system for unison sync..."
|
||||
vm.ssh.upload!(StringIO.new(TemplateRenderer.render('/unison/script')), config.unison.script)
|
||||
|
@ -69,6 +59,16 @@ module Vagrant
|
|||
ssh.exec!("sudo rm #{config.unison.crontab_entry_file}", :error_check => false)
|
||||
end
|
||||
|
||||
def create_unison(ssh, opts)
|
||||
crontab_entry = TemplateRenderer.render('/unison/crontab_entry',
|
||||
:from => opts[:original][:guestpath],
|
||||
:to => opts[:guestpath],
|
||||
:options => config.unison.options,
|
||||
:script => config.unison.script)
|
||||
ssh.exec!("sudo echo \"#{crontab_entry}\" >> #{config.unison.crontab_entry_file}")
|
||||
ssh.exec!("crontab #{config.unison.crontab_entry_file}")
|
||||
end
|
||||
|
||||
def prepare_host_only_network
|
||||
# Remove any previous host only network additions to the
|
||||
# interface file.
|
||||
|
@ -117,17 +117,9 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def chown(ssh, dir)
|
||||
ssh.exec!("sudo chown #{config.ssh.username} #{dir}")
|
||||
end
|
||||
|
||||
def config
|
||||
vm.env.config
|
||||
end
|
||||
|
||||
def render_crontab_entry(opts)
|
||||
TemplateRenderer.render('crontab_entry', opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
* * * * * <%= scriptname %> '<%= from %>' '<%= to %>' '<%= options %>'
|
||||
* * * * * <%= script %> '<%= from %>' '<%= to %>' '<%= options %>'
|
||||
|
|
|
@ -70,39 +70,22 @@ class LinuxSystemTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
# context "setting up an sync folder" do
|
||||
# setup do
|
||||
# @ssh.stubs(:exec!)
|
||||
# end
|
||||
context "creating unison entry" do
|
||||
setup do
|
||||
@ssh.stubs(:exec!)
|
||||
@options = {
|
||||
:guestpath => "foo",
|
||||
:original => { :guestpath => "bar" }
|
||||
}
|
||||
end
|
||||
|
||||
# should "create the new rysnc destination directory" do
|
||||
# sync_path = 'foo'
|
||||
# @ssh.expects(:exec!).with("sudo mkdir -p #{sync_path}")
|
||||
# @instance.create_sync(@ssh, :syncpath => "foo")
|
||||
# end
|
||||
# TODO Test crontab entry
|
||||
|
||||
# should "add an entry to the crontab file" do
|
||||
# @instance.expects(:render_crontab_entry).returns('foo')
|
||||
# @ssh.expects(:exec!).with do |cmd|
|
||||
# cmd =~ /echo/ && cmd =~ /foo/ && cmd =~ /#{@mock_env.config.vm.sync_crontab_entry_file}/
|
||||
# end
|
||||
# @instance.create_sync(@ssh, {})
|
||||
# end
|
||||
|
||||
# should "use the crontab entry file to define vagrant users cron entries" do
|
||||
# @ssh.expects(:exec!).with("crontab #{@mock_env.config.vm.sync_crontab_entry_file}")
|
||||
# @instance.create_sync(@ssh, {})
|
||||
# end
|
||||
|
||||
# should "chown the sync directory" do
|
||||
# @instance.expects(:chown).with(@ssh, "foo")
|
||||
# @instance.create_sync(@ssh, :syncpath => "foo")
|
||||
# end
|
||||
|
||||
# should "return provide a formatted crontab entry that runs every minute" do
|
||||
# assert @instance.render_crontab_entry({}).include?("* * * * *")
|
||||
# end
|
||||
# end
|
||||
should "enable the crontab file" do
|
||||
@ssh.expects(:exec!).with("crontab #{@mock_env.config.unison.crontab_entry_file}")
|
||||
@instance.create_unison(@ssh, @options)
|
||||
end
|
||||
end
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# "Private" methods tests
|
||||
|
|
Loading…
Reference in New Issue