Police were warned that the gunman who killed seven people and wounded 25 in Texas last month was planning an attack eight years ago, according to newly revealed police reports.

Seth Ator’s mother reported to cops in February 2011 that her son was refusing to take his mental health medication and had threatened to kill himself in a shootout with police, CNN reported.

The worried mom shared a recording with cops, in which Ator declared “911 will bow down before me.”

When officers in Amarillo, Texas, showed up to her home in 2011, they found what they interpreted as preparations for an attack — a machete hidden in Ator’s bed and an underground shelter he’d dug in the backyard.

“There seemed to be some indication of some planned stand-off with police,” one of the officers wrote in a report.

Another officer wrote he believed that Ator, then 28, was violent and would “attempt to harm the police and public” one day.

Eight years later, on Aug. 31, Ator opened fire on a Texas state trooper during a traffic stop and then continued on a rampage through the cities of Midland and Odessa, shooting people first from his car and then from a hijacked USPS truck.

Police eventually cornered and killed Ator in the parking lot of a Cinergy movie theater.

After inspecting the home in 2011, cops took Ator to a hospital and he was eventually admitted to The Pavilion, a mental health treatment facility.

While there, Ator told security: “The police can’t be everywhere,” according to one of the reports.

“I took this as a threat against the public,” an officer wrote.

Two days later, Ator’s mother told cops that he was being released by The Pavilion.

Amarillo Police Department Chief Ed Drain told CNN he didn’t know what more his officers could have done to prevent the shooting.

“It’s clear that the shooter had mental problems, but we have something called the Constitution, and that prohibits us from just locking people up,” said Drain, who joined the department as chief in 2016, after the Ator interaction.

“Broad criteria like these threats are not enough to bring criminal charges.”

The department now uploads violent-person files to state and federal databases — but didn’t back in 2011, Drain said.

“This shooter fell off our radar,” said Drain.

Records show that Ator suffered from mental health issues throughout his life and had been institutionalized in 2001 and 2006.

Despite failing a background check in 2014 for an attempted firearms purchase, Ator was able to buy the AR-15-style rifle he used in last month’s attack.

Because the sale was private, and not via a licensed gun seller, there was no legal requirement to conduct a background check.

Federal investigators searched the Lubbock, Texas, home of the alleged gun-seller earlier this month.