Section 42. If, when a town votes to establish a municipal lighting plant, any person or municipality was, at the time of the first vote required by section thirty-five or thirty-six, engaged in generating or distributing gas or electricity for sale for lighting purposes in such town, the town may purchase of him or it, at such price and on such terms as may be agreed upon, such portion of his or its plant and property within the limits of such town as such town desires for its use and as can be agreed upon, provided, however, that no such purchase shall be consummated by a city unless approved by vote of its city council, or of its commissioners if the city government consists of a commission, or by a town unless ratified by the voters at a town meeting.