示例#1
0
    def checkArgs(self):
        """ check command line arguments """

        if not self.opts['type']:
            Wrapper.error('-t not given')

        return
示例#2
0
    def checkArgc(self):
        """ check command line argument count """

        if len(sys.argv) == 1:
            Wrapper.error('-H for help and usage')

        return
示例#3
0
    def checkInstallType(self):
        """ check chosen installation type or list available types """

        types = ['text', 'curses']

        if self.opts['type'] == '?':
            Wrapper.info('supported installation types', color='normal')
            Wrapper.info('text', color='normal', verbose=True)
            Wrapper.info('curses', color='normal', verbose=True)
            sys.exit(SUCCESS)

        if self.opts['type'] not in types:
            Wrapper.error('unknown installation type: ' + self.opts['type'])

        return
示例#4
0
    def printHeader():
        """ print header """

        Wrapper.line('-' * TextInstaller.getTermWidth(), color='red', bold=True)
        Wrapper.line('--==[ blackarch-installer ]==--', color='white', bold=True)
        Wrapper.line('-' * TextInstaller.getTermWidth(), color='red', bold=True)
        print('\n')

        return
示例#5
0
    def printHeader():
        """ print header """

        Wrapper.line('-' * TextInstaller.getTermWidth(),
                     color='red',
                     bold=True)
        Wrapper.line('--==[ blackarch-installer ]==--',
                     color='white',
                     bold=True)
        Wrapper.line('-' * TextInstaller.getTermWidth(),
                     color='red',
                     bold=True)
        print('\n')

        return
示例#6
0
def main(wrapper_start_args):
    # same as old 'use-readline = True'
    better_console = wrapper_start_args.betterconsole
    encoding = wrapper_start_args.encoding

    config = getjsonfile("wrapper.properties", ".", encodedas=encoding)

    if config and "Misc" in config:
        if "use-betterconsole" in config["Misc"]:
            # use readline = not using better_console
            better_console = (config["Misc"]["use-betterconsole"])

    configure_logger(betterconsole=better_console)

    # develop master passphrase for wrapper
    secret_key = wrapper_start_args.passphrase
    if len(secret_key) < 8 and secret_key != 'none':
        secret_key = get_passphrase(
            'please input a master passphrase for Wrapper.  This passphrase '
            'will be used to encrypt sensitive information in Wrapper.\n>')
    if secret_key == "none":
        secret_key = False

    # __init__ wrapper and set up logging
    wrapper = Wrapper(secret_key)
    log = wrapper.log

    # start first wrapper log entry
    log.info("Wrapper.py started - Version %s", wrapper.getbuildstring())
    log.debug("Wrapper is using Python %s.%s.", sys.version_info[0], SUBVER)

    # flag python version problems
    if SUBVER < MINSUB:
        log.warning(
            "You are using Python %s.%s.  There are Wrapper dependencies"
            " and methods that may require a minimum version of %s.%s."
            " Please press <y> and <Enter> to acknowledge and continue"
            " (anything else to exit)..." % (VERSION, SUBVER, VERSION, MINSUB))
        userstdin = sys.stdin.readline().strip()
        if userstdin.lower() != "y":
            print("bye..")
            sys.exit(1)

    # start wrapper
    # noinspection PyBroadException
    try:
        wrapper.start()
    except SystemExit:
        if not wrapper.configManager.exit:
            os.system("reset")
        wrapper.plugins.disableplugins()

        # save-all is required to have a flush argument
        wrapper.javaserver.console("save-all flush")
        wrapper.javaserver.stop("Wrapper.py received shutdown signal - bye")
        wrapper.halt.halt = True
    except Exception as ex:
        log.critical("Wrapper.py crashed - stopping server to be safe (%s)",
                     ex,
                     exc_info=True)
        wrapper.halt.halt = True
        wrapper.plugins.disableplugins()
        try:
            wrapper.javaserver.stop("Wrapper.py crashed - please contact"
                                    " the server host as soon as possible")
        except AttributeError as exc:
            log.critical(
                "Wrapper has no server instance. Server is likely "
                "killed but could still be running, or it "
                "might be corrupted! (%s)",
                exc,
                exc_info=True)
示例#7
0
    def getInstallMode():
        """ get installation mode """

        count = 0
        answer = ''

        while answer not in ('1', '2', '3'):
            if count >= 1:
                Wrapper.warn('incorrect mode\n')
            Wrapper.info('installation modes:')
            Wrapper.info('1. install from live-iso', verbose=True)
            Wrapper.info('2. install from repository', verbose=True)
            Wrapper.info('3. install from sources using blackman', verbose=True)
            answer = Wrapper.ask('select mode: ')
            count += 1

        return answer
示例#8
0
    def printSection(section):
        """ print section heading message """

        Wrapper.line('>> ' + section + '\n\n')

        return
示例#9
0
    def getInstallMode():
        """ get installation mode """

        count = 0
        answer = ''

        while answer not in ('1', '2', '3'):
            if count >= 1:
                Wrapper.warn('incorrect mode\n')
            Wrapper.info('installation modes:')
            Wrapper.info('1. install from live-iso', verbose=True)
            Wrapper.info('2. install from repository', verbose=True)
            Wrapper.info('3. install from sources using blackman',
                         verbose=True)
            answer = Wrapper.ask('select mode: ')
            count += 1

        return answer
示例#10
0
    def printSection(section):
        """ print section heading message """

        Wrapper.line('>> ' + section + '\n\n')

        return
示例#11
0
def main(wrapper_start_args):
    # same as old 'use-readline = True'
    better_console = wrapper_start_args.betterconsole
    encoding = wrapper_start_args.encoding

    config = getjsonfile("wrapper.properties", ".", encodedas=encoding)

    if config and "Misc" in config:
        if "use-betterconsole" in config["Misc"]:
            # use readline = not using better_console
            better_console = (config["Misc"]["use-betterconsole"])

    configure_logger(betterconsole=better_console)

    # develop master passphrase for wrapper
    secret_key = wrapper_start_args.passphrase
    if len(secret_key) < 8:
        secret_key = get_passphrase(
            'please input a master passphrase for Wrapper.  This passphrase '
            'will be used to encrypt sensitive information in Wrapper.\n>')

    # __init__ wrapper and set up logging
    wrapper = Wrapper(secret_key)
    log = wrapper.log

    # start first wrapper log entry
    log.info("Wrapper.py started - Version %s", wrapper.getbuildstring())
    log.debug("Wrapper is using Python %s.%s.%s.", VERSION, SUBVER, MICRO)

    # flag python version problems
    if SUBVER < MINSUB:
        log.warning(
            "You are using Python %s.%s.  There are Wrapper dependencies"
            " and methods that may require a minimum version of %s.%s."
            " Please press <y> and <Enter> to acknowledge and continue"
            " (anything else to exit)..." %
            (VERSION, SUBVER, VERSION, MINSUB))
        userstdin = sys.stdin.readline().strip()
        if userstdin.lower() != "y":
            print("bye..")
            sys.exit(1)

    # start wrapper
    # noinspection PyBroadException
    try:
        wrapper.start()

    except SystemExit:
        if not wrapper.configManager.exit:
            os.system("reset")
        wrapper.plugins.disableplugins()
        wrapper.alerts.ui_process_alerts(
            "Wrapper called SystemExit exception",
            blocking=True
        )

        # save-all is required to have a flush argument
        wrapper.javaserver.console("save-all flush")
        wrapper.javaserver.stop("Wrapper.py received shutdown signal - bye")
        wrapper.haltsig.halt = True

    except ImportWarning as ex:
        crash_mess = ("Wrapper.py Could not start due to missing requests "
                      "module: \n%s" % ex)
        wrapper.alerts.ui_process_alerts(crash_mess, blocking=True)
        log.critical(crash_mess)

    except Exception as ex:
        crash_mess = ("Wrapper crashed - stopping server to be safe (%s)" % ex)
        wrapper.alerts.ui_process_alerts(crash_mess, blocking=True)
        log.critical("Wrapper.py crashed - stopping server to be safe (%s)",
                     ex, exc_info=True)
        wrapper.haltsig.halt = True
        wrapper.plugins.disableplugins()
        try:
            wrapper.javaserver.stop("Wrapper.py crashed - please contact"
                                    " the server host as soon as possible")
        except AttributeError as exc:
            log.critical("Wrapper has no server instance. Server is likely "
                         "killed but could still be running, or it "
                         "might be corrupted! (%s)", exc, exc_info=True)