ยง 6301. Grounds for preliminary injunction and temporary restraining order. A preliminary injunction may be granted in any action where it appears that the defendant threatens or is about to do, or is doing or procuring or suffering to be done, an act in violation of the plaintiff's rights respecting the subject of the action, and tending to render the judgment ineffectual, or in any action where the plaintiff has demanded and would be entitled to a judgment restraining the defendant from the commission or continuance of an act, which, if committed or continued during the pendency of the action, would produce injury to the plaintiff. A temporary restraining order may be granted pending a hearing for a preliminary injunction where it appears that immediate and irreparable injury, loss or damage will result unless the defendant is restrained before the hearing can be had.