コード例 #1
0
ファイル: user_com.py プロジェクト: Rondore/sitewrangler
def _add(sys_user):
    from libsw import user
    if sys_user:
        if user.exists(sys_user):
            print('Error. ' + sys_user + ' already exists.')
            return
    else:
        sys_user = user.select_new_username()
    user.make_user(sys_user)
コード例 #2
0
ファイル: email_com.py プロジェクト: Rondore/sitewrangler
def _setdomain(domain, more):
    from libsw import email, user, cert
    sys_user = False
    if domain == False:
        domain = email.select_domain()
    elif more != False:
        sys_user = more[0]
        if not user.exists(sys_user):
            sys_user = False
    if sys_user == False:
        sys_user = user.select_user()
    email.SetMailDomain(domain, sys_user).run()
    if cert.has_cert(domain):
        cert.deploy_exim_domain(domain)
        cert.update_dovecot_ssl()
コード例 #3
0
def _disable(username, more):
    from libsw import ssh, user
    if not username or not user.exists(username):
        username = user.select_user(True)
    key = False
    if more:
        key = more[0]
    else:
        key = ssh.select_key('Select a key to disable', username, enabled=True)
        if not key:
            print(username + ' has no authorized SSH keys')
            return
    removed = ssh.KeyDisabler(username, key).run()
    if removed:
        print('Successfully disabled key')
    else:
        print('Key was not authorized for ' + username)
コード例 #4
0
def _import(username):
    from libsw import ssh, user
    if not username or not user.exists(username):
        username = user.select_user(True)
    print(
        'If you are using Unix or a Unix-like system such as Linux or OSX, you can copy this code into your local terminal to get your SSH key including the decorators you need for this command:'
    )
    print(
        '''mkdir -p ~/.ssh; if [ ! -f ~/.ssh/id_rsa ]; then ssh-keygen -N "" -f ~/.ssh/id_rsa >/dev/null; fi; echo "Your full public key:"; cat ~/.ssh/id_rsa.pub'''
    )
    print()
    key = input(
        'Enter the full public key lines as it appears in id_rsa.pub (or similar): '
    )
    error = ssh.add(key, username)
    if error:
        print('Error: ' + error)
    else:
        print('Added Key for ' + username)
コード例 #5
0
ファイル: nginx_com.py プロジェクト: Rondore/sitewrangler
def _add(domain, more):
    from libsw import nginx, user, cert
    if domain == False:
        domain = input_util.input_domain()
    username = False
    template = False
    if more != False:
        username = more[0]
        if len(more) > 1:
            template = more[1]
    if username != False and not user.exists(username):
        username = False
    if username == False:
        username = user.select_user()
    hide_ssl = True
    if cert.has_cert(domain):
        hide_ssl = False
    if template == False:
        template = nginx.choose_template("Select a vhost template: ", hide_ssl)
    nginx.make_vhost(username, domain, template)
コード例 #6
0
def _remove(username, more):
    from libsw import ssh, user
    if not username or not user.exists(username):
        username = user.select_user(True)
    key = False
    if more:
        key = more[0]
    else:
        print(
            'If you are using Unix or a Unix-like system such as Linux or OSX, you can copy this code into your local terminal to get your naked SSH key:'
        )
        print(
            '''mkdir -p ~/.ssh; if [ ! -f ~/.ssh/id_rsa ]; then ssh-keygen -N "" -f ~/.ssh/id_rsa >/dev/null; fi; echo "Your naked public key:"; cat ~/.ssh/id_rsa.pub'''
        )
        key = ssh.select_key('Select a key to delete', username)
        if not key:
            print(username + ' has no authorized SSH keys')
            return
    removed = ssh.KeyRemover(username, key).run()
    if removed:
        print('Successfully removed key')
    else:
        print('Key was not authorized for ' + username)
コード例 #7
0
def _add(domain, more):
    from libsw import cert, user, nginx, email
    sys_user = False
    nomail = False
    if domain == False:
        domain = input_util.input_domain()
    if more != False:
        if user.exists(more[0]):
            sys_user = more[0]
        if len(more) > 1 and more[1].lower() == 'nomail':
            nomail = True
        elif sys_user.lower() == 'nomail':
            sys_user = False
            nomail = True
    if sys_user == False:
        sys_user = nginx.user_from_domain(domain)
    if sys_user == False:
        sys_user = user.select_user()
    if nomail:
        cert.create_nomail_le_certs(domain, sys_user)
    else:
        cert.create_std_le_certs(domain, sys_user)
    if email.is_domain(domain):
        cert.deploy_exim_domain(domain)