Пример #1
0
def install(packages):
    """
    Install a list of packages.
    """
    if distroFamily() == 'debian':
        sudo('/usr/bin/apt-get --yes --quiet install {}'.format(" ".join(packages)))
    elif distroFamily() == 'fedora':
        sudo('/usr/bin/yum install -y {}'.format(" ".join(packages)))
    else:
        abort('Unknown distro.')
Пример #2
0
def update():
    """
    Update package list.
    """
    if distroFamily() == 'debian':
        sudo('/usr/bin/apt-get update')
    elif distroFamily() == 'fedora':
        # Automatic
        pass
    else:
        abort('Unknown distro.')
Пример #3
0
def update():
    """
    Update package list.
    """
    if distroFamily() == 'debian':
        sudo('/usr/bin/apt-get update')
    elif distroFamily() == 'fedora':
        # Automatic
        pass
    elif distroFamily() == 'freebsd':
        sudo('/usr/sbin/pkg update')
    else:
        abort('Unknown distro.')
Пример #4
0
def install(packages):
    """
    Install a list of packages.
    """
    if distroFamily() == 'debian':
        sudo('/usr/bin/apt-get --yes --quiet install {}'.format(
            " ".join(packages)))
    elif distroFamily() == 'fedora':
        sudo('/usr/bin/yum install -y {}'.format(" ".join(packages)))
    elif distroFamily() == 'freebsd':
        sudo('/usr/sbin/pkg install -y {}'.format(" ".join(packages)))
    else:
        abort('Unknown distro.')
Пример #5
0
def createService(username, base='/srv', groups=['service']):
    """
    Create a service user.
    """
    if fails('/usr/bin/id {}'.format(username)):
        if distroFamily() in ['debian', 'fedora']:
            if groups:
                groupOpt = '--group ' + ','.join(groups)
            else:
                groupOpt = ''
            if base is not None:
                baseOpt = '--base-dir {}'.format(base)
            else:
                baseOpt = ''
            sudo('/usr/sbin/useradd {} {} --user-group '
                 '--create-home --system --shell /bin/bash '
                 '{}'.format(baseOpt, groupOpt, username))
        elif distroFamily() == 'freebsd':
            if groups:
                abort("Groups not supported")
            if base:
                abort("Basedir not supported")
            return sudo(
                '/usr/sbin/pw useradd -m -s /usr/local/bin/bash -h - -n {}'.
                format(username))
        else:
            abort('Unknown distro')
Пример #6
0
def createService(username, base='/srv', groups=['service']):
    """
    Create a service user.
    """
    if fails('/usr/bin/id {}'.format(username)):
        if distroFamily() in ['debian', 'fedora']:
            if groups:
                groupOpt = '--group ' + ','.join(groups)
            else:
                groupOpt = ''
            if base is not None:
                baseOpt = '--base-dir {}'.format(base)
            else:
                baseOpt = ''
            sudo('/usr/sbin/useradd {} {} --user-group '
                 '--create-home --system --shell /bin/bash '
                 '{}'.format(baseOpt, groupOpt, username))
        elif distroFamily() == 'freebsd':
            if groups:
                abort("Groups not supported")
            if base:
                abort("Basedir not supported")
            return sudo('/usr/sbin/pw useradd -m -s /usr/local/bin/bash -h - -n {}'.format(username))
        else:
            abort('Unknown distro')