1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00
metasploit-framework/msfupdate

67 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
# -*- coding: binary -*-
# $Id$
# $Revision$
msfbase = __FILE__
while File.symlink?(msfbase)
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
@args = ARGV.dup
Dir.chdir(File.dirname(msfbase))
$stderr.puts "[*]"
$stderr.puts "[*] Attempting to update the Metasploit Framework..."
$stderr.puts "[*]"
$stderr.puts ""
if not (Process.uid == 0 or File.stat(msfbase).owned?)
$stderr.puts "[-] ERROR: User running msfupdate does not own the metasploit install"
$stderr.puts "Please run msfupdate as the same user who installed metasploit."
end
have_configdir = false
2012-10-01 19:41:36 +02:00
wait_index = nil
@args.each_with_index do |arg,i|
if arg == "wait"
wait_index = i
end
next unless arg =~ /--config-dir/
have_configdir = true
end
2012-10-01 19:41:36 +02:00
if wait_index
@args.delete_at wait_index
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.
@args.push("--config-dir=#{configdir}")
end
@args.push("--non-interactive")
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", *@args)
end
2012-10-01 19:41:36 +02:00
if wait_index
$stderr.puts ""
$stderr.puts "[*] Please hit enter to exit"
$stderr.puts ""
$stdin.readline
end