Exemple #1
0
def bootstrap():
    """
    Set up a new server (requires superuser credentials).
    """
    # Very important that we only do this on remote machines and not locally.
    if not env.host_string:
        abort('You must specify a server to configure using -H.')

    # Use sudo if we're not logging on as root
    if env.user != 'root':
        env.sudo = True

    # Bootstrap stuff
    _bootstrap.software()
    _bootstrap.user()
    _bootstrap.project()

    # Initial code deploy
    code.deploy(warn=False)

    # Initial puppet run
    puppet.run()

    # Fix permissions
    _bootstrap.chown()
Exemple #2
0
def bootstrap():
    """
    Set up a new server.
    """
    # Very important that we only do this on remote machines and not locally.
    if not env.host_string:
        abort('You must specify a server to configure using -H.')

    # Use sudo if we're not logging on as root
    if env.user != 'root':
        env.sudo = True

    # Bootstrap stuff
    _bootstrap.software()
    _bootstrap.user()
    _bootstrap.project()

    # Initial code deploy
    code.deploy(warn=False)

    # Initial puppet run
    puppet.run()

    # Fix permissions
    _bootstrap.chown()
Exemple #3
0
def deploy():
    """
    Deploy to remote environment.

    Deploys code from the current git branch to the remote server and reloads
    services so that the new code is in effect.

    The remote server to deploy to is automatically determined based on the
    currently checked-out git branch and matched to the configuration specified
    in fabfile/deploy/config.py.
    """
    code.deploy()
    # Post-deploy tasks on the remote server
    with settings(host_string=servers.remote()):
        build()
        puppet.run()
        app.reload()
Exemple #4
0
def deploy():
    """
    Deploy to remote environment.

    Deploys code from the current git branch to the remote server and reloads
    services so that the new code is in effect.

    The remote server to deploy to is automatically determined based on the
    currently checked-out git branch and matched to the configuration specified
    in fabfile/deploy/config.py.
    """
    code.deploy()
    # Post-deploy tasks on the remote server
    with settings(host_string=servers.remote()):
        build()
        puppet.run()
        app.restart()
Exemple #5
0
def _open_channels(ssh, paths, f, rec, preserve, check_hash):
    # Check if pyscp is available on remote
    stdin, stdout, stderr = ssh.exec_command("pyscp -h")
    while (not stdout.channel.exit_status_ready()):
        time.sleep(5. / 60.)  # 5s
    if (stdout.channel.recv_exit_status() == 0):
        stdin, stdout, stderr = _exec_command(ssh, "pyscp", paths,
                                              f, rec, preserve, check_hash)
    else:
        remote_tempfile = dep.deploy(ssh)
        if (not remote_tempfile):
            raise Exception("Deployment failed")

        stdin, stdout, stderr = \
            _exec_command(ssh, "python2 '{}'".format(remote_tempfile), paths,
                          f, rec, preserve, check_hash)

    return stdin, stdout, stderr
Exemple #6
0
''' Main Module for Project '''

import sys
import scrapper
import deployment
import report_builder

if __name__ == "__main__":
    if len(sys.argv) > 1:
        if sys.argv[1] == '-d':
            deployment.deploy()

    scrapper = scrapper.Scrapper()
    report_builder = report_builder.ReportBuilder()

    report_builder.print_reports(scrapper.scrape())
Exemple #7
0
                'than using linux-user-chroot')

    if app.config.get('instances'):
        app.spawn()

    while True:
        try:
            compose(defs, target)
            break
        except KeyboardInterrupt:
            app.log(target, 'Interrupted by user')
            os._exit(1)
        except app.RetryException:
            pass
        except:
            import traceback
            traceback.print_exc()
            app.log(target, 'Exiting: uncaught exception')
            os._exit(1)

    if app.config.get('reproduce'):
        app.log('REPRODUCED',
                'Matched %s of' % len(app.config['reproduced']),
                app.config['tasks'])
        for match in app.config['reproduced']:
            print match[0], match[1]

    if target.get('kind') == 'cluster' and app.config.get('fork') is None:
        with app.timer(target, 'cluster deployment'):
            deploy(defs, target)
Exemple #8
0
def home():
    ''' Function that handles all page interaction. Renders the
    page based off of templating. Allows us to detect the payload
    selection and kick off the deployment scripts. '''

    # instantiate all payload selection buttons/forms
    form = PayloadSelection()

    if form.validate_on_submit():
        if form.arm_karma.data:
            payload = "setup.cfg.karma"
            config = "/home/pi/P4wnp1/setup.cfg"
            choice = "KARMA"
        elif form.arm_jammer.data:
            payload = "rc.local"
            config = "/etc/rc.local"
            payload2 = "setup.cfg.deauth"
            config2 = "/home/pi/P4wnp1/setup.cfg"
            choice = "WiFi Jamming"
        elif form.arm_io.data:
            payload = "setup.cfg.io"
            config = "/home/pi/P4wnp1/setup.cfg"
            choice = "IO Message"
        elif form.arm_cam.data:
            payload = "setup.cfg.camera"
            config = "/home/pi/P4wnp1/setup.cfg"
            choice = "Webcam Disruption"
        elif form.arm_geo.data:
            payload = "setup.cfg.geo"
            config = "/home/pi/P4wnp1/setup.cfg"
            choice = "Geolocate"
        elif form.arm_hail.data:
            payload = "setup.cfg.hailmary"
            config = "/home/pi/P4wnp1/setup.cfg"
            choice = "Hail Mary"

        if payload2:
            deploy(payload2, config2)
        failures = deploy(payload, config)
        failed = str(len(failures)) + "." + "".join(failures)
        return flask.render_template("armed.html",
                                     failed=failed,
                                     choice=choice)
    '''
    # handle submit button press and launch script
    if karma.validate_on_submit():
        if karma.arm_karma.data:
            print(os.system("ls"))

    if jammer.validate_on_submit():
        if jammer.arm_jammer.data:
            print(os.system("ps"))
            return flask.render_template("armed.html")

    if io.validate_on_submit():
        if io.arm_io.data:
            print(os.system("ps"))

    if cam_disrupt.validate_on_submit():
        if cam_disrupt.arm_cam.data:
            print(os.system("ps"))

    if geolocate.validate_on_submit():
        if geolocate.arm_geo.data:
            print(os.system("ps"))
    '''

    return flask.render_template("index.html", form=form)
Exemple #9
0
app.cleanup(app.config['tmp'])

with app.timer('TOTAL'):
    lockfile = open(os.path.join(app.config['tmp'], 'lock'), 'r')
    fcntl.flock(lockfile, fcntl.LOCK_SH | fcntl.LOCK_NB)

    target = os.path.join(app.config['defdir'], app.config['target'])
    app.log('TARGET', 'Target is %s' % target, app.config['arch'])
    with app.timer('DEFINITIONS', 'parsing %s' % app.config['def-version']):
        defs = Definitions()
    with app.timer('CACHE-KEYS', 'cache-key calculations'):
        cache.cache_key(defs, app.config['target'])
    defs.save_trees()

    sandbox.executor = sandboxlib.executor_for_platform()
    app.log(app.config['target'], 'Sandbox using %s' % sandbox.executor)
    if sandboxlib.chroot == sandbox.executor:
        app.log(app.config['target'], 'WARNING: rogue builds in a chroot ' +
                'sandbox may overwrite your system')

    if app.config.get('instances'):
        app.spawn()

    done = False
    while not done:
       try:
           done = assemble(defs, app.config['target'])
       except:
           pass
    deploy(defs, app.config['target'])
Exemple #10
0
            app.config['target'], 'WARNING: using chroot is less safe ' +
            'than using linux-user-chroot')

    if 'instances' in app.config:
        app.spawn()

    while True:
        try:
            compose(defs, target)
            break
        except KeyboardInterrupt:
            app.log(target, 'Interrupted by user')
            os._exit(1)
        except app.RetryException:
            pass
        except:
            import traceback
            traceback.print_exc()
            app.log(target, 'Exiting: uncaught exception')
            os._exit(1)

    if app.config.get('reproduce'):
        app.log('REPRODUCED', 'Matched %s of' % len(app.config['reproduced']),
                app.config['tasks'])
        for match in app.config['reproduced']:
            print match[0], match[1]

    if target.get('kind') == 'cluster' and app.config.get('fork') is None:
        with app.timer(target, 'cluster deployment'):
            deploy(defs, target)
import os
import re
import deployment
from remote_hosts_list import __REMOTE_HOSTS_LIST__
from dirs_to_deploy_list import __DIRS_TO_DEPLOY_LIST__

addon_id = re.sub("deploy_", "", os.path.basename(__file__))[:-3]
deployment = deployment.Deployment()
deployment.deploy(__REMOTE_HOSTS_LIST__, [
    next(deploy_dir for deploy_dir in __DIRS_TO_DEPLOY_LIST__
         if deploy_dir["id"] == addon_id)
])
Exemple #12
0
            config['target'], 'WARNING: using chroot is less safe ' +
            'than using linux-user-chroot')

    if 'instances' in config:
        spawn()

    while True:
        try:
            compose(target)
            break
        except KeyboardInterrupt:
            log(target, 'Interrupted by user')
            os._exit(1)
        except RetryException:
            pass
        except:
            import traceback
            traceback.print_exc()
            log(target, 'Exiting: uncaught exception')
            os._exit(1)

    if config.get('reproduce'):
        log('REPRODUCED', 'Matched %s of' % len(config['reproduced']),
            config['tasks'])
        for match in config['reproduced']:
            print match[0], match[1]

    if target.get('kind') == 'cluster' and config.get('fork') is None:
        with timer(target, 'cluster deployment'):
            deploy(target)
Exemple #13
0
        log(config['target'], 'WARNING: using chroot is less safe ' +
            'than using linux-user-chroot')

    if 'instances' in config:
        spawn()

    while True:
        try:
            compose(target)
            break
        except KeyboardInterrupt:
            log(target, 'Interrupted by user')
            os._exit(1)
        except RetryException:
            pass
        except:
            import traceback
            traceback.print_exc()
            log(target, 'Exiting: uncaught exception')
            os._exit(1)

    if config.get('reproduce'):
        log('REPRODUCED',
            'Matched %s of' % len(config['reproduced']), config['tasks'])
        for match in config['reproduced']:
            print match[0], match[1]

    if target.get('kind') == 'cluster' and config.get('fork') is None:
        with timer(target, 'cluster deployment'):
            deploy(target)