`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)
|
def mount_shared_folder(ssh, name, guestpath)
|
||||||
ssh.exec!("sudo mkdir -p #{guestpath}")
|
ssh.exec!("sudo mkdir -p #{guestpath}")
|
||||||
mount_folder(ssh, name, guestpath)
|
mount_folder(ssh, name, guestpath)
|
||||||
chown(ssh, guestpath)
|
ssh.exec!("sudo chown #{config.ssh.username} #{guestpath}")
|
||||||
end
|
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)
|
def prepare_unison(ssh)
|
||||||
logger.info "Preparing system for unison sync..."
|
logger.info "Preparing system for unison sync..."
|
||||||
vm.ssh.upload!(StringIO.new(TemplateRenderer.render('/unison/script')), config.unison.script)
|
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)
|
ssh.exec!("sudo rm #{config.unison.crontab_entry_file}", :error_check => false)
|
||||||
end
|
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
|
def prepare_host_only_network
|
||||||
# Remove any previous host only network additions to the
|
# Remove any previous host only network additions to the
|
||||||
# interface file.
|
# interface file.
|
||||||
|
@ -117,17 +117,9 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def chown(ssh, dir)
|
|
||||||
ssh.exec!("sudo chown #{config.ssh.username} #{dir}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def config
|
def config
|
||||||
vm.env.config
|
vm.env.config
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_crontab_entry(opts)
|
|
||||||
TemplateRenderer.render('crontab_entry', opts)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
# context "setting up an sync folder" do
|
context "creating unison entry" do
|
||||||
# setup do
|
setup do
|
||||||
# @ssh.stubs(:exec!)
|
@ssh.stubs(:exec!)
|
||||||
# end
|
@options = {
|
||||||
|
:guestpath => "foo",
|
||||||
|
:original => { :guestpath => "bar" }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# should "create the new rysnc destination directory" do
|
# TODO Test crontab entry
|
||||||
# sync_path = 'foo'
|
|
||||||
# @ssh.expects(:exec!).with("sudo mkdir -p #{sync_path}")
|
|
||||||
# @instance.create_sync(@ssh, :syncpath => "foo")
|
|
||||||
# end
|
|
||||||
|
|
||||||
# should "add an entry to the crontab file" do
|
should "enable the crontab file" do
|
||||||
# @instance.expects(:render_crontab_entry).returns('foo')
|
@ssh.expects(:exec!).with("crontab #{@mock_env.config.unison.crontab_entry_file}")
|
||||||
# @ssh.expects(:exec!).with do |cmd|
|
@instance.create_unison(@ssh, @options)
|
||||||
# cmd =~ /echo/ && cmd =~ /foo/ && cmd =~ /#{@mock_env.config.vm.sync_crontab_entry_file}/
|
end
|
||||||
# end
|
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
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
# "Private" methods tests
|
# "Private" methods tests
|
||||||
|
|
Loading…
Reference in New Issue