diff options
Diffstat (limited to 'framework/src/suricata/qa/prscript.py')
-rwxr-xr-x | framework/src/suricata/qa/prscript.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/framework/src/suricata/qa/prscript.py b/framework/src/suricata/qa/prscript.py index 4f401edd..02dd0ad9 100755 --- a/framework/src/suricata/qa/prscript.py +++ b/framework/src/suricata/qa/prscript.py @@ -72,6 +72,7 @@ parser.add_argument('-d', '--docker', action='store_const', const=True, help='us parser.add_argument('-C', '--create', action='store_const', const=True, help='create docker container' + docker_deps, default=False) parser.add_argument('-s', '--start', action='store_const', const=True, help='start docker container' + docker_deps, default=False) parser.add_argument('-S', '--stop', action='store_const', const=True, help='stop docker container' + docker_deps, default=False) +parser.add_argument('-R', '--rm', action='store_const', const=True, help='remove docker container and image' + docker_deps, default=False) parser.add_argument('branch', metavar='branch', help='github branch to build', nargs='?') args = parser.parse_args() username = args.username @@ -227,9 +228,6 @@ if not args.local and TestRepoSync(args.branch) == -1: sys.exit(-1) def CreateContainer(): - if not os.geteuid() == 0: - print "Command must be run as root" - sys.exit(-1) cli = Client() # FIXME check if existing print "Pulling docking image, first run should take long" @@ -238,9 +236,6 @@ def CreateContainer(): sys.exit(0) def StartContainer(): - if not os.geteuid() == 0: - print "Command must be run as root" - sys.exit(-1) cli = Client() suri_src_dir = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] print "Using base src dir: " + suri_src_dir @@ -248,13 +243,24 @@ def StartContainer(): sys.exit(0) def StopContainer(): - if not os.geteuid() == 0: - print "Command must be run as root" - sys.exit(-1) cli = Client() cli.stop('suri-buildbot') sys.exit(0) +def RmContainer(): + cli = Client() + try: + cli.remove_container('suri-buildbot') + except: + print "Unable to remove suri-buildbot container" + pass + try: + cli.remove_image('regit/suri-buildbot:latest') + except: + print "Unable to remove suri-buildbot images" + pass + sys.exit(0) + if GOT_DOCKER: if args.create: CreateContainer() @@ -262,6 +268,8 @@ if GOT_DOCKER: StartContainer() if args.stop: StopContainer() + if args.rm: + RmContainer() if not args.branch: print "You need to specify a branch for this mode" |