__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:fabsetup 作者: theno 项目源码 文件源码
def server_customizations():
    '''Customize the server (user, authorized_keys, ...).'''

    username = env.user
    env.user = 'root'

    # create user
    all_users = run('cut -d: -f1 /etc/passwd').split()
    if username not in all_users:

        host = env.host

        run(flo('adduser {username}'))

        # add user to the sudo group, cf. http://askubuntu.com/a/7484
        #run('sudo adduser {username} sudo'.format(**locals()))
        # http://jeromejaglale.com/doc/unix/ubuntu_sudo_without_password
        append('/etc/sudoers', flo('{username} ALL=(ALL) NOPASSWD: ALL'),
               use_sudo=True)

        # set up password-less login
        local(flo('ssh-copy-id -i ~/.ssh/id_rsa.pub  {username}@{host}'))

        env.user = username

        # Disable service apache2 httpd, cf. http://askubuntu.com/a/355102
        sudo('update-rc.d apache2 disable')
    else:
        print(magenta(flo(' nothing to do, user {username} already exists')))
        env.user = username
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号