コード例 #1
0
def setup_startup_script(install_dir, nexus_current_dir_name, sym_linked_nexus_dir, nexus_username):
    full_current_dir = os.path.join(install_dir, nexus_current_dir_name)
    startup_script_path = os.path.join(full_current_dir, 'bin/nexus')

    if not fabric_exists('/etc/init.d/nexus'):
        with cd('/etc/init.d'):
            sudo('ln -s ' + startup_script_path + ' /etc/init.d/nexus')
            sudo('chmod 755 /etc/init.d/nexus')
            sudo('update-rc.d nexus defaults')

    # Edit the init script changing the following variables:
    #    * Change NEXUS_HOME to the absolute folder location e.g. NEXUS_HOME="/usr/local/nexus"
    #    * Set the RUN_AS_USER to nexus or any other user with restricted rights that you want to use to run the service
    #
    # update nexus home first
    before = 'NEXUS_HOME=\".+\"'
    after = 'NEXUS_HOME=\"' + sym_linked_nexus_dir + '\"'
    fabric_sed(startup_script_path, before, after, use_sudo=True, backup='.bak')

    # make sure the RUN_AS_USER variable is not commented out
    fabric_uncomment(startup_script_path, 'RUN_AS_USER='******'#', backup='.bak')

    # now update RUN_AS_USER
    before = '^\s*RUN_AS_USER=.*'
    after = 'RUN_AS_USER=\"' + nexus_username + '\"'
    fabric_sed(startup_script_path, before, after, use_sudo=True, backup='.bak')
コード例 #2
0
def backup_existing_install(install_dir, install_options):

    with cd(install_dir):
        # move the current nexus install into a backup dir
        if fabric_exists(install_options['nexus_current_dir_name']):
            sudo('mv %(nexus_current_dir_name)s %(nexus_old_dir_name)s' %
                 install_options)
コード例 #3
0
 def exists(self, path, use_sudo=False, verbose=False):
     def _expand_path(path):
         return '"$(echo %s)"' % path
     if self.local_deployment:
         with settings(hide('output'), warn_only=True):
             return not self.run('test -e {}'.format(_expand_path(self.fmt(path)))).failed
     return fabric_exists(self.fmt(path), use_sudo=use_sudo, verbose=verbose)
コード例 #4
0
ファイル: operations.py プロジェクト: alexmerser/ops
def exists(path, use_sudo=False, verbose=False):
    require('hosts')
    if 'localhost' in env.hosts:
        capture = not verbose
        command = 'test -e "%s"' % path
        func = use_sudo and sudo or run
        with settings(hide('everything'), warn_only=True):
            return not func(command, capture=capture).failed
    else:
        return fabric_exists(path, use_sudo, verbose)
コード例 #5
0
def migrate_previous_install(install_dir, install_options, migrate_from):

    with cd(install_dir):
        # copy over the nexus conf dir
        if migrate_from is not None:
            sudo('mkdir -p %(nexus_current_dir_name)s/../sonatype-work' % install_options)
            sudo('rsync -pr %(migrate_from)s/conf %(nexus_current_dir_name)s/conf && rsync -pr %(migrate_from)s/../sonatype-work %(nexus_current_dir_name)s/..' % install_options)

        elif fabric_exists(install_options['nexus_current_dir_name']):
            sudo('rsync -pr %(nexus_old_dir_name)s/conf %(nexus_current_dir_name)s/conf' % install_options)
コード例 #6
0
def exists(path, use_sudo=False, verbose=False):
    require('hosts')
    if 'localhost' in env.hosts:
        capture = not verbose
        command = 'test -e "%s"' % path
        func = use_sudo and sudo or run
        with settings(hide('everything'), warn_only=True):
            return not func(command, capture=capture).failed
    else:
        return fabric_exists(path, use_sudo, verbose)
コード例 #7
0
def migrate_previous_install(install_dir, install_options, migrate_from):

    with cd(install_dir):
        # copy over the nexus conf dir
        if migrate_from is not None:
            sudo('mkdir -p %(nexus_current_dir_name)s/../sonatype-work' %
                 install_options)
            sudo(
                'rsync -pr %(migrate_from)s/conf %(nexus_current_dir_name)s/conf && rsync -pr %(migrate_from)s/../sonatype-work %(nexus_current_dir_name)s/..'
                % install_options)

        elif fabric_exists(install_options['nexus_current_dir_name']):
            sudo(
                'rsync -pr %(nexus_old_dir_name)s/conf %(nexus_current_dir_name)s/conf'
                % install_options)
コード例 #8
0
def setup_downloaded_version(install_dir, install_options):

    with cd(install_dir):
        # move the extracted directory from the working directory to the correct one
        sudo('mv %(created_dir)s %(nexus_current_dir_name)s' % install_options)

        symlink = install_options['sym_linked_nexus_dir']

        # delete the symlink if it exists
        if fabric_exists(symlink):
            sudo('rm ' + symlink)

        # recreate nexus symlink
        parent_dir = os.path.dirname(symlink)
        print(parent_dir)
        with cd(parent_dir):
            sudo('ln -s ' + install_dir + '/%(nexus_current_dir_name)s nexus' % install_options)
コード例 #9
0
def setup_downloaded_version(install_dir, install_options):

    with cd(install_dir):
        # move the extracted directory from the working directory to the correct one
        sudo('mv %(created_dir)s %(nexus_current_dir_name)s' % install_options)

        symlink = install_options['sym_linked_nexus_dir']

        # delete the symlink if it exists
        if fabric_exists(symlink):
            sudo('rm ' + symlink)

        # recreate nexus symlink
        parent_dir = os.path.dirname(symlink)
        print(parent_dir)
        with cd(parent_dir):
            sudo('ln -s ' + install_dir +
                 '/%(nexus_current_dir_name)s nexus' % install_options)
コード例 #10
0
def setup_startup_script(install_dir, nexus_current_dir_name,
                         sym_linked_nexus_dir, nexus_username):
    full_current_dir = os.path.join(install_dir, nexus_current_dir_name)
    startup_script_path = os.path.join(full_current_dir, 'bin/nexus')

    if not fabric_exists('/etc/init.d/nexus'):
        with cd('/etc/init.d'):
            sudo('ln -s ' + startup_script_path + ' /etc/init.d/nexus')
            sudo('chmod 755 /etc/init.d/nexus')
            sudo('update-rc.d nexus defaults')

    # Edit the init script changing the following variables:
    #    * Change NEXUS_HOME to the absolute folder location e.g. NEXUS_HOME="/usr/local/nexus"
    #    * Set the RUN_AS_USER to nexus or any other user with restricted rights that you want to use to run the service
    #
    # update nexus home first
    before = 'NEXUS_HOME=\".+\"'
    after = 'NEXUS_HOME=\"' + sym_linked_nexus_dir + '\"'
    fabric_sed(startup_script_path,
               before,
               after,
               use_sudo=True,
               backup='.bak')

    # make sure the RUN_AS_USER variable is not commented out
    fabric_uncomment(startup_script_path,
                     'RUN_AS_USER='******'#',
                     backup='.bak')

    # now update RUN_AS_USER
    before = '^\s*RUN_AS_USER=.*'
    after = 'RUN_AS_USER=\"' + nexus_username + '\"'
    fabric_sed(startup_script_path,
               before,
               after,
               use_sudo=True,
               backup='.bak')
コード例 #11
0
def mountDrives(force=False):
    if conf['hdd']['auto_mount'] or force:
        for mpoint in conf['hdd']['mount_locations']:
            if not fabric_exists(mpoint['mount_point']):
                runCmd("mkdir -p %s" % mpoint['mount_point'])
            runCmd("mount %s %s" % (mpoint['drive'], mpoint['mount_point']))
コード例 #12
0
def backup_existing_install(install_dir, install_options):

    with cd(install_dir):
        # move the current nexus install into a backup dir
        if fabric_exists(install_options['nexus_current_dir_name']):
            sudo('mv %(nexus_current_dir_name)s %(nexus_old_dir_name)s' % install_options)
コード例 #13
0
ファイル: __init__.py プロジェクト: brooklynpacket/fabutil
def exists(remote_path):
    return fabric_exists(remote_path)
コード例 #14
0
ファイル: fabfile.py プロジェクト: aekazakov/bootstrap
def mountDrives(force=False):
    if conf['hdd']['auto_mount'] or force:
        for mpoint in conf['hdd']['mount_locations']:
            if not fabric_exists(mpoint['mount_point']):
                runCmd("mkdir -p %s" % mpoint['mount_point'])
            runCmd("mount %s %s" % (mpoint['drive'],mpoint['mount_point']))