]> git.llucax.com Git - software/pymin.git/blob - pymind
Move ip_forward activation from config to pymind.
[software/pymin.git] / pymind
1 #!/usr/bin/env python
2 # vim: set encoding=utf-8 et sw=4 sts=4 :
3
4 import sys
5 import logging ; log = logging.getLogger('pymind')
6
7 from pymin.pymindaemon import PyminDaemon
8 from pymin.dispatcher import Handler
9 from pymin.service import load_service, LoadError
10 import config
11
12 # exit status
13 EXIT_NO_SERVICE = 1
14
15 class Root(Handler):
16     pass
17
18 def build_root(config):
19     # TODO check services dependencies
20     services = dict()
21     for service in config.services:
22         try:
23             s = load_service(service, config.services_dirs)
24         except LoadError, e:
25             log.error("Can't find service called '%s'\n", service)
26             sys.exit(EXIT_NO_SERVICE)
27         services[service] = s
28     root = Root()
29     for name, service in services.items():
30         setattr(root, name, service.get_service(config))
31     return root
32
33 # FIXME
34 try:
35     f = file("/proc/sys/net/ipv4/ip_forward","w")
36     f.write("1")
37     f.close()
38 except (IOError, OSError), e:
39     log.warning("Can't set ip_forward: %s", e)
40
41 PyminDaemon(build_root(config), config.bind_addr).run()
42