root/netsukuku/trunk/pyntk/ntkd

Revision 1339, 2.1 kB (checked in by eriol, 1 year ago)

Removed tabs

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env python
2 ##
3 # This file is part of Netsukuku
4 # (c) Copyright 2007 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
5 #
6 # This source code is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as published
8 # by the Free Software Foundation; either version 2 of the License,
9 # or (at your option) any later version.
10 #
11 # This source code 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.
14 # Please refer to the GNU Public License for more details.
15 #
16 # You should have received a copy of the GNU Public License along with
17 # this source code; if not, write to:
18 # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ##
20
21 import sys
22 from ntk.ntkd import NtkNode
23 from ntk.lib.opt import Opt, OptErr
24 from ntk.lib.micro import allmicro_run
25 from config import *
26
27 usage = """
28 ntkd [n=nics_list] [c=config]
29
30
31      n=['nic1', 'nic2', ...]        explicit nics to use
32
33      c="/path/to/config/file.conf"  configuration file path
34
35      ipv=4 or ipv=6                 IP version
36
37      dbg=0..9                       debug level (default 0)
38      v or version                   version
39      h or help                      this help
40 """
41
42 def main():
43
44     # load options
45     opt = Opt( {'n':'nics',
46                 'c':'config_file',
47                 'v':'version',
48                 '-v':'version',
49                 'h':'help',
50                 '-h':'help',
51                 'dbg':'debug'
52                 } )
53     opt.config_file = CONF_DIR + '/netsukuku.conf'
54     opt.load_argv(sys.argv)
55
56     if opt.help:
57         print usage
58         sys.exit(1)
59     if opt.version:
60         print "NetsukukuD " + VERSION
61         sys.exit(1)
62
63     if opt.config_file:
64         opt.load_file(opt.config_file)
65         opt.load_argv(sys.argv)
66
67     if opt.debug:
68         import logging
69         logging.basicConfig(level=logging.DEBUG,
70                             format='%(levelname)s %(message)s')
71
72     NtkNode(opt).run()
73
74     allmicro_run()
75
76 if __name__ == "__main__":
77     main()
Note: See TracBrowser for help on using the browser.