Beispiel #1
0
def check_dpkg():
    purge_list = []
    with hide('stdout'):
        for i, line in enumerate(str(run('dpkg -l')).splitlines()):
            if i < 6:
                continue
            if line.startswith(b'ii'):
                continue
            line = line.strip()
            if line.startswith(b'rc'):
                purge_list.append(line.split()[1])
                continue
            print(line)
    if purge_list:
        sudo('aptitude -y purge ' + ' '.join(purge_list))
Beispiel #2
0
def user_env():
    homedir = str(run("dirname ~/.bashrc")).strip()
    prefixes = ['/usr/local', '/usr', '/', homedir]
    env_path = 'PATH="%s"' % ['%s/sbin:%s/bin' for p in prefixes]

    rf = RemoteFile('~/.bashrc')
    rf.content = find_or_add(
        rf.content,
        r'^PATH=(.*)$',
        env_path)
    rf.content = find_or_add(
        rf.content,
        r'^export EDITOR="?([^"]*)"?$',
        repl_rlinput('export EDITOR="%s"', 'editor: ', config['editor']))
    rf.update()
Beispiel #3
0
def check_dpkg():
    purge_list = []
    with hide('stdout'):
        for i, line in enumerate(str(run('dpkg -l')).splitlines()):
            if i < 6:
                continue
            if line.startswith(b'ii'):
                continue
            line = line.strip()
            if line.startswith(b'rc'):
                purge_list.append(line.split()[1])
                continue
            print(line)
    if purge_list:
        sudo('aptitude -y purge ' + ' '.join(purge_list))
Beispiel #4
0
def user_env():
    homedir = str(run("dirname ~/.bashrc")).strip()
    prefixes = [
        '/usr/local',
        '/usr',
        '',
    ]
    pathes = ':'.join(['%s/sbin:%s/bin' % (p, p) for p in prefixes])
    env_path = 'PATH="%s:%s/bin"' % (pathes, homedir)

    rf = RemoteFile('~/.bashrc')
    rf.content = find_or_add(rf.content, r'^PATH=(.*)$', env_path)
    rf.content = find_or_add(
        rf.content, r'^export EDITOR="?([^"]*)"?$',
        repl_rlinput('export EDITOR="%s"', 'editor: ', config['editor']))
    rf.update()
Beispiel #5
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRh\
bmqr5tyjwQIRnqi4BMGY2CPbiGf/3EvWf shell@201602',
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJMb4giDpPu\
Vu0qi6YT9KhoK/dIidy6TE4OlocuchWFR mobile@201602'
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" >> ~/.ssh/authorized_keys' % key)
Beispiel #6
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRhbmqr5tyjwQIRnqi4BMGY2CPbiGf\
/3EvWf shell@201602',
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" > ~/.ssh/authorized_keys' % key)
Beispiel #7
0
def pubkey():
    pubkeys = [
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIANXSjD8YRh\
bmqr5tyjwQIRnqi4BMGY2CPbiGf/3EvWf shell@201602',
        'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJMb4giDpPu\
Vu0qi6YT9KhoK/dIidy6TE4OlocuchWFR mobile@201602'
    ]

    run('mkdir -p ~/.ssh/')
    run('chmod 700 ~/.ssh')
    run('touch ~/.ssh/authorized_keys')
    run('chmod 600 ~/.ssh/authorized_keys')

    for key in pubkeys:
        with settings(warn_only=True):
            r = run('grep "%s" ~/.ssh/authorized_keys' % key)
            if r.succeeded:
                continue
        run('echo "%s" >> ~/.ssh/authorized_keys' % key)