def adduser(login="******", name="Majerti", firstname="Admin", primary_group="1"): """ Add a user to the database """ password = gen_random_str(10) md5_pass = md5(password).hexdigest() cmd = "echo \"INSERT INTO egw_accounts (account_lid, account_pwd, account_firstname, \ account_lastname, account_status, account_primary_group, \ account_email) VALUES ('{0}', '{1}', '{2}', '{3}', 'A', '{4}', \ '*****@*****.**');\" | mysql -uroot autonomie" .format(login, md5_pass, firstname, name, primary_group) launch_cmd(cmd) print "New password : {0}".format(password)
def adduser(login="******", name="Majerti", firstname="Admin", primary_group="1"): """ Add a user to the database """ password = gen_random_str(10) md5_pass = md5(password).hexdigest() cmd = "echo \"INSERT INTO egw_accounts (account_lid, account_pwd, account_firstname, \ account_lastname, account_status, account_primary_group, \ account_email) VALUES ('{0}', '{1}', '{2}', '{3}', 'A', '{4}', \ '*****@*****.**');\" | mysql -uroot autonomie".format( login, md5_pass, firstname, name, primary_group) launch_cmd(cmd) print "New password : {0}".format(password)
def gen_database(dbname="autonomie", user="******"): """ generates a database and a specific user and generates a random password """ password = gen_random_str() if os.path.isdir("/var/lib/mysql/{0}".format(dbname)): print "The database {0} already exists, only modifying password".format( dbname) sql_cmds = get_sql_grant_cmds(user, password, dbname) else: sql_cmds = get_sql_create_cmds(user, password, dbname) sql_cmds.extend(get_sql_grant_cmds(user, password, dbname)) for sql_cmd in sql_cmds: bash_cmd = get_bash_cmd(sql_cmd) launch_cmd(bash_cmd) return password