diff options
author | Rob Austein <sra@hactrn.net> | 2014-04-05 22:42:12 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-04-05 22:42:12 +0000 |
commit | fe0bf509f528dbdc50c7182f81057c6a4e15e4bd (patch) | |
tree | 07c9a923d4a0ccdfea11c49cd284f6d5757c5eda /ca/rpki-start-servers | |
parent | aa28ef54c271fbe4d52860ff8cf13cab19e2207c (diff) |
Source tree reorg, phase 1. Almost everything moved, no file contents changed.
svn path=/branches/tk685/; revision=5757
Diffstat (limited to 'ca/rpki-start-servers')
-rwxr-xr-x | ca/rpki-start-servers | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/ca/rpki-start-servers b/ca/rpki-start-servers new file mode 100755 index 00000000..edaffb2e --- /dev/null +++ b/ca/rpki-start-servers @@ -0,0 +1,76 @@ +#!/usr/bin/env python + +# $Id$ +# +# Copyright (C) 2014 Dragon Research Labs ("DRL") +# Portions copyright (C) 2009--2013 Internet Systems Consortium ("ISC") +# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notices and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL, +# ISC, OR ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" +Start servers, using config file to figure out which servers the user +wants started. +""" + +import subprocess +import os +import argparse +import sys +import time +import rpki.config +import rpki.autoconf + +os.environ["TZ"] = "UTC" +time.tzset() + +parser = argparse.ArgumentParser(description = __doc__) +parser.add_argument("-c", "--config", + help = "override default location of configuration file") +parser.add_argument("-d", "--debug", action = "store_true", + help = "enable debugging") +parser.add_argument("--logdir", default = ".", + help = "where to write write log files when debugging") +args = parser.parse_args() + +cfg = rpki.config.parser(args.config, "myrpki") + +def run(name): + # pylint: disable=E1103 + cmd = (os.path.join(rpki.autoconf.libexecdir, name), "-c", cfg.filename) + if args.debug: + proc = subprocess.Popen(cmd + ("-d",), + stdout = open(os.path.join(args.logdir, name + ".log"), "a"), + stderr = subprocess.STDOUT) + else: + proc = subprocess.Popen(cmd) + if args.debug and proc.poll() is None: + print "Started %s, pid %s" % (name, proc.pid) + elif not args.debug and proc.wait() == 0: + print "Started %s" % name + else: + print "Problem starting %s, pid %s" % (name, proc.pid) + + +if cfg.getboolean("start_irdbd", cfg.getboolean("run_rpkid", False)): + run("irdbd") + +if cfg.getboolean("start_rpkid", cfg.getboolean("run_rpkid", False)): + run("rpkid") + +if cfg.getboolean("start_pubd", cfg.getboolean("run_pubd", False)): + run("pubd") + +if cfg.getboolean("start_rootd", cfg.getboolean("run_rootd", False)): + run("rootd") |