--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/iro-install Thu Sep 27 17:15:46 2012 +0200
@@ -0,0 +1,97 @@
+#!/usr/bin/env python2.7
+
+# Copyright (c) 2012 netzguerilla.net <iro@netzguerilla.net>
+#
+# This file is part of Iro.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal in
+# the Software without restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
+# #Software, and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+from twisted.python import log
+
+from sqlalchemy import create_engine, pool
+from sqlalchemy.exc import ArgumentError
+import sys,os
+
+import logging
+
+from iro.controller.pool import dbPool
+from iro import config, __version__, install
+
+observer = log.PythonLoggingObserver()
+observer.start()
+
+logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s')
+
+import argparse
+
+parser = argparse.ArgumentParser(description='Iro installer.')
+parser.add_argument('-v', '--version', action='version', version="%s %s"%(os.path.basename(sys.argv[0]),__version__))
+parser.add_argument('--install', action='store_true',
+ help='will create the right database layout.')
+parser.add_argument('--update', action='store_true',
+ help='will install all routes and providers.')
+args = parser.parse_args()
+
+if not install.checkConfig():
+ install.createSampleConfig()
+ logging.info("Please edit iro.conf")
+ sys.exit(1)
+
+config.init()
+
+try:
+ engine = create_engine(config.main.dburl,
+ poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, )
+except ArgumentError:
+ logging.error("Can't connect to database")
+ logging.info("Please edit iro.conf")
+ sys.exit(1)
+
+
+if not install.checkDatabaseConnection():
+ logging.error("Can't connect to database")
+ logging.info("Please edit iro.conf")
+ sys.exit(1)
+
+if not install.checkDatabase():
+ logging.error("Database not in right format.")
+ if args.install:
+ install.createDatabase()
+ logging.info("Database layout created.")
+ else:
+ logging.info("Please edit iro.conf and run %s --install"%os.path.basename(sys.argv[0]))
+ sys.exit(1)
+
+routes = [ s for s in config.configParser.sections() if not s in ["main",]]
+ao = install.getAllRoutes(routes, False)
+for o in ao["orphand"]:
+ logging.info("Offer(%s) is orphand (no route using this offer)."%o)
+if ao["added"]:
+ if args.install or args.update:
+ ao = install.getAllRoutes(routes,True)
+ for a in ao["added"]:
+ logging.info("Added Offer(%s)"%a)
+ logging.info('Updated offerlist.')
+ else:
+ logging.warning('offerlist is not up-to-date.')
+ logging.info("Please run %s --update"%os.path.basename(sys.argv[0]))
+ sys.exit(1)
+
+logging.info("You can just start your iro server.")
+
+