1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-10-29 18:07:27 +01:00
metasploit-framework/msfupdate

54 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
msfbase = __FILE__
while File.symlink?(msfbase)
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
Dir.chdir(File.dirname(msfbase))
$stderr.puts "[*]"
$stderr.puts "[*] Attempting to update the Metasploit Framework..."
$stderr.puts "[*]"
$stderr.puts ""
if not ::File.stat(msfbase).owned?
$stderr.puts "[-] ERROR: user running msfupdate does not own the metasploit install"
end
wait = (ARGV.shift.to_s == "wait")
have_configdir = false
ARGV.each do |arg|
next unless arg =~ /--config-dir/
have_configdir = true
end
unless have_configdir
configdir = File.join(File.dirname(msfbase), "data", "svn")
# Spaces in the directory should be fine since this whole thing is passed
# as a single argument via the multi-arg syntax for system() below.
ARGV.push("--config-dir=#{configdir}")
end
res = system("svn", "cleanup")
if res.nil?
$stderr.puts "[-] ERROR: Failed to run svn"
$stderr.puts ""
$stderr.puts "[-] If you used a binary installer, make sure you run the symlink in"
$stderr.puts "[-] /usr/local/bin instead of running this file directly (e.g.: ./msfupdate)"
$stderr.puts "[-] to ensure a proper environment."
else
# Cleanup worked, go ahead and update
system("svn", "update", *ARGV)
end
if wait
$stderr.puts ""
$stderr.puts "[*] Please hit enter to exit"
$stderr.puts ""
$stdin.readline
end