def _drop_db_accounts(self): logger.info("Dropping databases associated with {0}".format(self.shortname)) for provisioned_db in self.databases: try: provisioned_db._drop() except: if not shell.is_forced(): raise try: logger.info("Dropping PostgreSQL user account {0}".format(self.db_username)) if not shell.is_pretend(): conn, cur = Database._postgres() cur.execute("DROP OWNED BY {0};".format(self.db_username)) cur.execute("DROP ROLE {0};".format(self.db_username)) cur.execute('SELECT pg_reload_conf();') cur.close() conn.close() except: if not shell.is_forced(): raise try: logger.info("Dropping MySQL user account {0}".format(self.db_username_mysql)) if not shell.is_pretend(): conn, cur = Database._mysql() cur.execute("DROP USER '{0}'@'localhost';".format(self.db_username_mysql)) cur.close() conn.close() except: if not shell.is_forced(): raise
def _shell_delete(self): for service in ("httpd.sh", "php.sh"): do("sudo -u {0} {1} stop".format(self.shortname, shell.join(self._get_home(), "bin", service))) do("pkill -u {0}".format(self.shortname), ignore_errors=True) wait("Waiting for services to be removed from process list") try: self._drop_db_accounts() except: if not shell.is_forced(): raise do("rm /etc/sudoers.d/{0}".format(self.shortname)) do("rm /etc/piccolo/nginx/{0}.conf".format(self.shortname)) do("rm -rf /etc/piccolo/nginx/{0}_domains".format(self.shortname)) do("userdel -r {0}".format(self.shortname)) do("groupdel {0}".format(self.shortname), ignore_errors=True)