def _remove(sys_user, more): from libsw import user deletefiles = False if more != False and more[0].lower() == 'dropfiles': deletefiles = True if sys_user == False: sys_user = user.select_user() user.remove_user(sys_user, deletefiles)
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()
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)
def _add(domain, more): from libsw import php if not domain: domain = input_util.input_domain() sys_user = False php_version = False if more: sys_user = more[0] if len(more) > 1: php_version = more[1] else: php_version = php.select_version() else: from libsw import user sys_user = user.select_user() php_version = php.select_version() php.make_vhost(sys_user, domain, php_version)
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)
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)
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)
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)
#!/usr/bin/env python3 import os from libsw import php, nginx, user def make_php_site(user, domain, php_version): php.make_vhost(user, domain, php_version) nginx.make_vhost(user, domain) if __name__ == '__main__': user = user.select_user() domain = input('New Domain: ') php_version = php.select_version() make_php_site(user, domain, php_version)