1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#!/usr/bin/env ruby
=begin
ALIEN ARENA CONFIG CHECK (for server admins) V1.0
Copyright (C) 2009 Tony Jackson
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Tony Jackson can be contacted at tonyj@cooldark.com
=end
# Program starts here
# $* is array of args
if $*.include?('--help') then
puts ''
puts 'Server config check utility for Alien Arena'
puts ''
puts ' Checks map files listed in each .cfg sv_maplist are present in data1/maps'
puts ''
puts ' Usage:'
puts ' check-configs'
puts ' Optional arguments:'
puts ''
puts ' --help This message'
puts ' -all Also check against 3rd party maps in arena/maps directory'
puts ''
exit
end
mappath1st = "../../data1/maps/"
mappath3rd = "../../arena/maps/"
if File.exists?(mappath1st) and File.directory?(mappath1st) then
maps1stparty = Dir.entries(mappath1st)
else
maps1stparty = Array.new
end
if File.exists?(mappath3rd) and File.directory?(mappath3rd) then
maps3rdparty = Dir.entries(mappath3rd)
else
maps3rdparty = Array.new
end
Dir.foreach("../../arena/") do |entry|
if entry.split('.')[1] == 'cfg' then
cfgFile = File.open('../../arena/'+entry, 'r')
# read file and get sv_maplist line
while (line = cfgFile.gets)
if line.split(' ')[1] == 'sv_maplist' then
maplist = line.split(' ')[2..-1].map! {|map| map.gsub(/\"/, '') }
end
end
if maplist == nil then
puts "#{entry}: warning - sv_maplist not specified"
else
maplist.each { |map|
if $*.include?('-all') then
if !maps1stparty.include?(map+'.bsp') and !maps3rdparty.include?(map+'.bsp') then
puts "#{entry}: sv_maplist error - #{map}.bsp is not present in data1/maps or arena/maps"
end
else
if !maps1stparty.include?(map+'.bsp') then
puts "#{entry}: sv_maplist error - #{map}.bsp is not present in data1/maps"
end
end
}
end
cfgFile.close
end
end
|