Created
April 29, 2014 18:05
-
-
Save chiradeep/11407727 to your computer and use it in GitHub Desktop.
Ruby script to ssh into base wheezy template and install stuff necessary for systemvm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'net/ssh' | |
host = '' | |
user = 'root' | |
pass = 'root' | |
options = {} | |
opt_parser = OptionParser.new do |opts| | |
opts.banner = "Usage: provision.rb IP [options]" | |
opts.separator "" | |
opts.separator "Specific options:" | |
opts.on(:REQUIRED, "-u","--user", String, "Username (e.g., root)") do |u| | |
options[:user] = u | |
end | |
opts.on(:REQUIRED, "-p", "--password", String, "Password for user") do |p| | |
options[:pass] = p | |
end | |
end | |
begin | |
opt_parser.parse!(ARGV) | |
if ARGV.size == 1 | |
host = ARGV[0] | |
end | |
unless options[:user] && options[:pass] | |
raise OptionParser::MissingArgument | |
end | |
user = options[:user] | |
pass = options[:pass] | |
puts host, user, pass | |
rescue => e | |
puts e.message.capitalize | |
puts opt_parser.help() | |
exit 1 | |
end | |
Net::SSH.start( host, user, :password => pass ) do |ssh| | |
result = ssh.exec!("apt-get -q -y --force-yes --no-install-recommends install wget") | |
puts result | |
end | |
Net::SSH.start( host, user, :password => pass) do |ssh| | |
result = ssh.exec!("wget --no-check-certificate https://gist.githubusercontent.com/chiradeep/11388137/raw/51a98bfb61fd4cff6b282a43523c7d945f63416e/postinstall_lxc.sh -O postinstall.sh") | |
puts result | |
end | |
Net::SSH.start( host, user, :password => pass ) do |ssh| | |
result = ssh.exec!("chmod +x postinstall.sh") | |
puts result | |
end | |
Net::SSH.start( host, user, :password => pass ) do |ssh| | |
result = ssh.exec!("./postinstall.sh") | |
puts result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it actually work, do we have systemvms for LXC now?