Section 18. No person shall move a building in a public way without written permission from the selectmen or road commissioners, to be granted upon such terms as in their opinion the public safety may require; and the superior court shall have jurisdiction in equity to enforce this section.