def restart(command, argv): parser = argparse.ArgumentParser( description="Critic administration interface: restart", prog="criticctl [options] restart") parser.parse_args(argv) result = configtest("configtest", ["--quiet"]) if result != 0: print >>sys.stderr, "ERROR: System configuration is not valid." return result import os import subprocess system_identity = configuration.base.SYSTEM_IDENTITY try: os.seteuid(0) os.setegid(0) except OSError: print >>sys.stderr, "ERROR: 'criticctl restart' must be run as root." return 1 subprocess.check_call(["service", "apache2", "stop"]) subprocess.check_call(["service", "critic-" + system_identity, "restart"]) subprocess.check_call(["service", "apache2", "start"]) return 0
def restart(command, argv): parser = argparse.ArgumentParser( description="Critic administration interface: restart", prog="criticctl [options] restart") parser.parse_args(argv) result = configtest("configtest", ["--quiet"]) if result != 0: print >> sys.stderr, "ERROR: System configuration is not valid." return result import os import subprocess system_identity = configuration.base.SYSTEM_IDENTITY try: os.seteuid(0) os.setegid(0) except OSError: print >> sys.stderr, "ERROR: 'criticctl restart' must be run as root." return 1 subprocess.check_call(["service", "apache2", "stop"]) subprocess.check_call(["service", "critic-" + system_identity, "restart"]) subprocess.check_call(["service", "apache2", "start"]) return 0
def main(parser, show_help, command, argv): returncode = 0 if show_help or command is None: parser.print_help() else: if command == "listusers": listusers(argv) return 0 elif command == "adduser": adduser(argv) return 0 elif command == "deluser": deluser(argv) return 0 elif command in ("addrole", "delrole"): role(command, argv) return 0 elif command == "passwd": passwd(argv) return 0 elif command in ("connect", "disconnect"): return connect(command, argv) elif command == "configtest": return configtest(command, argv) elif command == "restart": return restart(command, argv) elif command == "stop": return stop(command, argv) elif command == "interactive": return interactive(command, argv) else: print >>sys.stderr, "ERROR: Invalid command: %s" % command returncode = 1 print """ Available commands are: listusers List all users. adduser Add a user. deluser Retire a user. addrole Add a role to a user. delrole Remove a role from a user. passwd Set or delete a user's password. connect Set up connection between user and external authentication provider. disconnect Remove such connection. configtest Test system configuration. restart Restart host WSGI container and Critic's background services. stop Stop host WSGI container and Critic's background services. interactive Drop into an interactive IPython shell. Use 'criticctl COMMAND --help' to see per command options.""" return returncode
def main(parser, show_help, command, argv): returncode = 0 if show_help or command is None: parser.print_help() else: if command == "listusers": listusers(argv) return 0 elif command == "adduser": adduser(argv) return 0 elif command == "deluser": deluser(argv) return 0 elif command in ("addrole", "delrole"): role(command, argv) return 0 elif command == "passwd": passwd(argv) return 0 elif command in ("connect", "disconnect"): return connect(command, argv) elif command == "configtest": return configtest(command, argv) elif command == "restart": return restart(command, argv) elif command == "stop": return stop(command, argv) elif command == "interactive": return interactive(command, argv) else: print >> sys.stderr, "ERROR: Invalid command: %s" % command returncode = 1 print """ Available commands are: listusers List all users. adduser Add a user. deluser Retire a user. addrole Add a role to a user. delrole Remove a role from a user. passwd Set or delete a user's password. connect Set up connection between user and external authentication provider. disconnect Remove such connection. configtest Test system configuration. restart Restart host WSGI container and Critic's background services. stop Stop host WSGI container and Critic's background services. interactive Drop into an interactive IPython shell. Use 'criticctl COMMAND --help' to see per command options.""" return returncode
def restart(command, argv): parser = argparse.ArgumentParser( description="Critic administration interface: restart", prog="criticctl [options] restart") parser.parse_args(argv) result = configtest("configtest", ["--quiet"]) if result != 0: print >>sys.stderr, "ERROR: System configuration is not valid." return result import os import subprocess system_identity = configuration.base.SYSTEM_IDENTITY try: os.seteuid(0) os.setegid(0) except OSError: print >>sys.stderr, "ERROR: 'criticctl restart' must be run as root." return 1 if configuration.base.WEB_SERVER_INTEGRATION == "apache": web_server_service = "apache2" elif configuration.base.WEB_SERVER_INTEGRATION in ("nginx+uwsgi", "uwsgi"): web_server_service = "uwsgi" else: web_server_service = None if web_server_service: subprocess.check_call(["service", web_server_service, "stop"]) subprocess.check_call(["service", "critic-" + system_identity, "restart"]) if web_server_service: subprocess.check_call(["service", web_server_service, "start"]) return 0
def restart(command, argv): parser = argparse.ArgumentParser( description="Critic administration interface: restart", prog="criticctl [options] restart") parser.parse_args(argv) result = configtest("configtest", ["--quiet"]) if result != 0: print >> sys.stderr, "ERROR: System configuration is not valid." return result import os import subprocess system_identity = configuration.base.SYSTEM_IDENTITY try: os.seteuid(0) os.setegid(0) except OSError: print >> sys.stderr, "ERROR: 'criticctl restart' must be run as root." return 1 if configuration.base.WEB_SERVER_INTEGRATION == "apache": web_server_service = "apache2" elif configuration.base.WEB_SERVER_INTEGRATION in ("nginx+uwsgi", "uwsgi"): web_server_service = "uwsgi" else: web_server_service = None if web_server_service: subprocess.check_call(["service", web_server_service, "stop"]) subprocess.check_call(["service", "critic-" + system_identity, "restart"]) if web_server_service: subprocess.check_call(["service", web_server_service, "start"]) return 0