We had major database crash and our master database got broken. Probably it will be rebuild so then we will have to configure logins and user mappings for sharepoint databases. Is there some kind of automatic way to do so, or maybe we have to do it manually according to Microsoft docs?
Even this could seems useless in your situation, please do a SQL Backup of your corrupted DBs, I can't promise you'll solved your problems usign this.
I did it once for a Content Database (in powershell):
$db = Get-SPDatabase "Your DB"; $db.Repair($true); $db.Update();
In stsadm there is also the line stsadm -o Databaserepair