Effect. The chief of police or any policeman of the city shall release any person arrested for a violation of the laws and ordinances of said city, upon said person giving a cash bond or surety bond with good and sufficient security to be approved by the chief of police or the assistant chief, or in their absence by the �nior officer on duty, payable to.the mayor of said city, in an amount fued by the said chief of police or the assistant chief, or in their absence by the senior officer on duty, for the personal appearance of such person before the police court of said city at the time and place therein specified, to answer the charges against him, and from time to time until the principal in such bond is tried and the case disposed or, and not to depart from thence except by leave of the court, except when the off ender is violent, in which case bail may be refused.