3 # IRC - Internet Relay Chat, tools/convert-conf.py
4 # Copyright (C) 2002 Alex Badea <vampire@p16.pub.ro>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 1, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # Configuration file converter from 2.10.11 to 2.10.12 format
23 # convert-conf.py < old.conf > new.conf
25 # $Id: convert-conf.py,v 1.1 2002-04-09 22:40:56 vampire Exp $
32 f = open(sys.argv[1], "r")
41 if not servers.has_key(parts[1]):
42 servers[parts[1]] = ['*', 0, 0, 0]
43 servers[parts[1]][1] = 1
45 jupes.append(parts[2])
48 if not servers.has_key(parts[3]):
49 servers[parts[3]] = ['*', 0, 0, 0]
50 servers[parts[3]][0] = parts[1]
51 servers[parts[3]][2] = 1
54 if not servers.has_key(parts[3]):
55 servers[parts[3]] = ['*', 0, 0, 0]
56 servers[parts[3]][0] = parts[1]
57 servers[parts[3]][3] = 1
60 print "#", join(parts, ":")
62 print "\tport = %s;" % parts[4]
64 print "\tmask = \"%s\";" % parts[1]
66 print "\tvhost = \"%s\";" % parts[2]
67 if count(parts[3], 'S'):
68 print "\tserver = yes;"
69 if count(parts[3], 'H'):
70 print "\thidden = yes;"
75 feats.append((parts[1], parts[2]))
78 'M': ('General', ('name', 'vhost', 'description', '', '!numeric'), ''),
79 'A': ('Admin', ('location', 'contact', 'contact'), ''),
80 'Y': ('Class', ('name', '!pingfreq', '!connectfreq', '!maxlinks', '!sendq'), ''),
81 'I': ('Client', ('ip', 'password', 'host', '', 'class'), ''),
82 'T': ('motd', ('host', 'file'), ''),
86 'K': ('Kill', ('host', 'reason'), ''),
87 'k': ('Kill', ('host', 'reason'), ''),
88 'C': ('Connect', ('host', 'password', 'name', '!port', 'class'), ''),
89 'D': ('CRULE', ('server', '', 'rule'), '\tall = yes;'),
90 'd': ('CRULE', ('server', '', 'rule'), ''),
91 'O': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = no;'),
92 'o': ('Operator', ('host', 'password', 'name', '', 'class'), '\tlocal = yes;'),
97 for line in f.readlines():
99 parts = split(line, ":")
102 if not cvtmap.has_key(parts[0]):
104 if callable(cvtmap[parts[0]]):
105 cvtmap[parts[0]](parts)
107 (block, items, extra) = cvtmap[parts[0]]
112 if idx >= len(parts):
114 if len(parts[idx]) and len(item):
116 print "\t%s = %s;" % (item[1:], parts[idx])
118 print "\t%s = \"%s\";" % (item, parts[idx])
125 for server in servers.keys():
126 (mask, uw, hub, leaf) = servers[server]
128 print "\tname = \"%s\";" % server
129 print "\tmask = \"%s\";" % mask
130 if uw: print "\tuworld = yes;"
131 if hub: print "\thub = yes;"
132 if leaf: print "\tleaf = yes;"
139 print "\tnick = \"%s\";" % nick
145 for (name, value) in feats:
146 print "\t\"%s\" = \"%s\";" % (name, value)