Section 20. No person who has been convicted of a violation of the provisions of section eleven, nineteen or twenty-three shall be eligible to election or appointment to any public office, or employment, nor as a teacher in any public or private educational institution, nor shall any person continue to hold any such office after final conviction. The superior court on petition of the attorney general shall have jurisdiction in equity to restrain and enjoin any such person from performing such duties thereafter and to prevent any such person’s name being placed on any ballot for election to any office. The court may upon petition in its discretion after a lapse of five years from the date of final conviction under sections eleven, nineteen or twenty-three remove the disability if in its opinion such person can then be adjudged to be loyal to the government of the commonwealth and the United States.