vehicle security systems also run the square body style switches under the hood for example. they may have a kit with brackets etc included which could work. some come with nuts on the threaded part so adjustments can be made.
example below. some units have dimensions in their ad.
https://www.ebay.com/itm/4-pcs-Unive...-/123152480661